# Data structures using Pseudocode with C

write an algorithm that accepts a linked list, traverses it and retrurns the data in the node with the minimum key value. ( data is the key ; so we should have to compare the data of each node until we find the minimum value)

My start ;

algorithm minimum  (val pList <head pointer>)

This algorithm accepts a link list , traverses it and returns the data in the node with the minimum key value.
Pre = pList is a valid pointer to the head of     the list
Post= the data with the minimum key value has been returned or in the case of an empty list , an invalid data is returned

If (fromwhere is 0)    start at first element
1 If (pList -> count is zero)
1 return ( invalid data value) checks null list

this is where I dont how to continue I can use a pWalker or a pList ->pos . one way or the other we have to keep track of where we are and where we are going , plus compare data nodes , I was going to use datakey as the variable to compare the data at each position .

then some how I have to move to the next node .If data is not less then what is in datakey ignore.Go to next data node until end of list and terminate.

2 pList ->pos = pList ->head
3 dataptr =  address ( pList -> pos -> data)
4 datakey <  data ( pList -> pos -> data ) compares data
5 sucess  = true

Now I am not sure what else to proceed with , and how to show the minimum key value . I could tell it to print it out  or can I display it to the screen.

any help would be greatly appreciated .
I am using the Data Structures Pseudocode Approach in C.
Gilberg and Forouzan

thank you
jerry
###### Who is Participating?

Commented:
I don't make a habit out of doing people's homework, but here's the process you should follow:

make a variable to hold value and initialize to 0.
make a pointer  of the same type as your list.
make while loop to check pointer->next != NULL
assign appropriate value:
value = (value > pointer->val) ? pointer->val : value;
increment pointer.

That should do it or at least point you in the right direction (no pun intended).
0

Author Commented:
Ellesd
Thanks for making me feel that young again. One should be careful on how he states his comments. However I am working for a Company as a IT and I am using a Data Structure book to learn Pseudocode Approach with C on my own.
Since I dont need the help anymore on this question , your answer was not usable for what I want .
I would like my points returned for future use.
If there is another proceedure that I must go thru please let me know.
thank you
Hope to work with you in the future.
0

OwnerCommented:
Nothing has happened on this question in over 9 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
accept answer by ellesd [or PAQ refund points] (asker got a good answer but rejected it and asked for a refund 3 weeks later).