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"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.