I am working on another linked list problem...really been struggling with this chapter dealing with lists...Here is the instruction for this example...

Write an algorithm to search a linked list with the first node pointed to by first for a given item and, if the item is found, return a pointer to the predecessor of the node containing the item...

I guess my major problem is I do not know how to perform a search and just want to see if I am on the right track...

float num = 0;
int number = 0;
ptr = first;
while (ptr! = null_value)
{
//perform the search
}
return ptr;

I am working on another linked list problem...really been struggling with this chapter dealing with lists...Here is the instruction for this example...

Write an algorithm to search a linked list with the first node pointed to by first for a given item and, if the item is found, return a pointer to the predecessor of the node containing the item...

I guess my major problem is I do not know how to perform a search and just want to see if I am on the right track...

float num = 0;
int number = 0;
ptr = first;
while (ptr! = null_value)
{
//perform the search
}
return ptr;

If this isn't pseudocode, you are definitely not on the right track. If it is pseudocode, then you need to add some more comments and explain what you are searching for. I've harped on this before. You need to either comment more or use far better variable name. num, number, ptr, first could be just about anything. numberToSearchFor, ptrToCurrentNode, and head are much better.

You're going to have to put something more than:

// perform the search

The whole code segment is the search, not just the part you have in the comment.

This article has been dead for over six months. Start a new discussion instead.