| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | [C] Solution to Qn.7 |
Hi Mallipeddi.
06-Jun-04 17:43:30, Mallipeddi Rajesh wrote to All
MR> From: "Mallipeddi Rajesh"
MR> >7. Finding if there is any loop inside linked list.Take two
MR> pointers(Pointer 1 and Pointer2) pointing to the first node and
MR> the second node respectively. With Pointer1 traverse the list
MR> leaving one node every time(i.e traversing only throughthe odd
MR> nodes)and do the same with Pointer 2 ,traversing the same list
MR> leaving one node every time but this pointer will be traversing
MR> through the even nodes only.If there is only one loop in the list
MR> then atleast one of these two pointers will reach the end(i.e
MR> Ptr->next==NULL).Then check if the other pointers next to next
MR> node is NULL or not. If it is NULL then there is no loop in the
MR> list.If not there is a loop
that sounds interesting, but as I understand traversing a list with a loop
will never end.
eg:
list-->[node1.next]-->[node2.next]-->[node3.next]-->[node4.next]--.
/|\ |
`---------------------------------------'
you seem to have implemented a solution which translates the problem into
the halting problem. :)
-=> Bye <=-
---
* Origin: Keyboard not connected, press to continue. (3:640/1042)SEEN-BY: 633/267 270 @PATH: 640/1042 531 954 774/605 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™.