![]() |
Minimum value in Linked List
How do I read through a Linked List and return the minimum value from a linked list. So it returns the element(s) that are the smallest?
Here is the struct struct names { char first[30]; char last[30]; struct names *next; }; struct names { char *first; char *last; struct names *next; }; struct names names_var; also how do I access the members of each structure? |
Re: Minimum value in Linked List
First you can't have structures with the same name.
To search a linked list you must iterate through the list and compare the node's value with the desired value. Jim |
Re: Minimum value in Linked List
The two structures are basically the same. But one has arrays and the other has pointers.
Now I was trying to is how do you access the members of each if you have a pointer for the structure var and var for the structure var. ie:struct names names_var; struct names *names_var; could some please write out code for the minimum value for a Linked list in the form of a function, with a return value and passing a structure? |
Re: Minimum value in Linked List
What I am trying to do in to learn how to find the minimum value of a linked list and return the value of the member that is the smallest.
using typedef struct names *pnames_var; pnames_var member; return member->fname;:shout::worried::cryin: PLease write out what's you are doing! code it for me please! John |
Re: Minimum value in Linked List
one way to code this is
Code:
#include <stdio.h> |
Re: Minimum value in Linked List
Is the head always the smallest? is the tail always the largest?
|
Re: Minimum value in Linked List
Quote:
Νο |
Re: Minimum value in Linked List
Can you show code that shows this? Con you do a conversion between arrays and linked list ie:
Code:
i=i+1 -> in linked listmin->fname? John:pleased::speechles:beatnik::euro::euro::juggl e::hang: |
Re: Minimum value in Linked List
I learn by doing rather than the frustration of doing something wrong and quitting.
Can someone please cods that shows that minimum value from a linked list where the minimum is not the head value? John |
| All times are GMT +5.5. The time now is 08:57. |