Data structures using Pseudocode with C

Posted on 2003-02-20
Medium Priority
Last Modified: 2010-04-15
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
Question by:jhook53
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

ellesd earned 200 total points
ID: 7991517
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.
point it at the head of 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).

Author Comment

ID: 8068571
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.
LVL 20

Expert Comment

ID: 10010887
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).


EE Cleanup Volunteer

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Suggested Courses
Course of the Month14 days, 18 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question