Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

circular linked list question

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
hi,
in a cicular link list, lets say I got
5 value stored. Each node has two links which points to the next and to the previous. Also the link is closed in
a sense that the last node has a link pointing to the first
node instead of setting it to NULL.

-Since this goes around, when I want to print out all the values how does C++ know when to stop, since there is no NULL?
-Do I have to count every value that is entered and use that total count in a loop to compare when I want to print out?

thankx i advance.
 
In a linked list you have written without libraries or templates, compare the pointer to the current node with the pointer to the head node. If they match, you are back at the beginning.
 
Squantto, please be sure to respond when you've read something you've felt was helpful. I personally have put a lot of effort into helping you, with no feedback, either positive or negative (see thread207-180340).
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top