jhook53
asked on
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 .
dataptr = address ( pList -> pos -> data) tracks address
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
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 .
dataptr = address ( pList -> pos -> data) tracks address
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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).
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
jmcg
EE Cleanup Volunteer
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).
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
jmcg
EE Cleanup Volunteer
ASKER
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
answer unexceptable
Hope to work with you in the future.