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
Solved

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maze travler 6 62
C++ assignment question 7 236
trigs fail! I thought I knew how to do trignometry 3 75
VS2015 Redefinition errors 4 68
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

856 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