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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looped linked list

Status
Not open for further replies.

longliz

Programmer
Joined
Feb 2, 2002
Messages
4
Location
US
hi i need to find a better way to determine if a linked list has a loop (anywhere ) - rather than by checking each pointer against all the others (which is a quadratic function). can some one please help??
longliz
 
Create new member of the list entry
bool AllreadyChecked;, construct it as AllreadyChecked=False;
then go through the list and test:
if(!AllreadyChecked) AllreadyChecked=True;
else Error("Loop detected");
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top