| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | RE: [C] Solution to Qn.7 |
From: "Roger Scudder" On Sunday, June 06, 2004 1:44 PM, Mallipeddi Rajesh wrote: > >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. That sounds like you read it out of a book. :-) Why don't you write a small sample program and post it here so we can test your algorithm on the computer? No only will it give you an excuse to write some code, it will be more fun for us as well. -Roger --- 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™.