Solved

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

Posted on 1997-07-08
2
179 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
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 30 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now