TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: All
from: Mallipeddi Rajesh
date: 2004-06-06 17:43:30
subject: [C] Solution to Qn.7

From: "Mallipeddi  Rajesh" 

  >7. Finding if there is any loop inside linked list.Take two pointers(Pointer
1 and Pointer2) pointing to the first node and the second node
respectively. With Pointer1 traverse the list leaving one node every
time(i.e traversing only throughthe odd nodes)and do the same with Pointer
2 ,traversing the same list leaving one node every time but this pointer
will be traversing through the even nodes only.If there is only one loop in
the list then atleast  one of these two pointers  will reach the end(i.e
Ptr->next==NULL).Then check if the other pointers next to next node is
NULL or not. If it is NULL then there is no loop in the list.If not there
is a loop.

--- BBBS/LiI v4.01 Flag-5
* Origin: Prism's_Point (1:261/38.1)
SEEN-BY: 633/267 270
@PATH: 261/38 123/500 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.