?
Solved

going to the begging of a linked list( the head node)

Posted on 1997-07-08
2
Medium Priority
?
186 Views
Last Modified: 2010-04-10
How do I go to the Head node in a linked list?  
I would need to do this when scaning and I want/need to scan from the begging.
0
Comment
Question by:kellyjj
[X]
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
2 Comments
 
LVL 3

Expert Comment

by:rmichels
ID: 1164539
not really sure if I have enuf information to answer you.  Usually when you have a linked list, you maintain a variable that points to the head (a pointer).  That way you can always reference the head.  Another method is that liked lists can have double links, that is each link points to it's sucessor and predecessor.  Working backwards thru the list,you stop when the predecessor is 0/null indicating the beginning of the list

0
 

Accepted Solution

by:
bradz earned 60 total points
ID: 1164540
If your lis only has single links, then you must hold the head pointer in your linked list class.

If double, then scan the node backwards until the node pnter is NULL.

Want the code for lnkdlst?? I can email it to you.

bradz
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

762 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