Solved

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

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

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

726 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