actually my question is this :

 suppose u have a linked list like this :

1--->2---->3---->4---->5------->6------->7------>8
                              ^                               |
                              |                               |
                              |                               v
                              10 <----------------------- 9        
 then how can u find the cycle here ..



On 5/14/06, deepblue <[EMAIL PROTECTED]> wrote:

Hi Arulanandan P,

I feel the best possible answer to this is:

Take 2 pointers and increment the first with 1 node and increment the
second with 2 nodes. Then after every increment check if the values of
the pointers are equal. And if they are equal then you can say that the
linked list has an infinite loop. :)

Also check for the end of the node. i.e., if the pointers contains null
walues.

Thanks for asking such brilliant question and keeping Computer Science
alive.

Regards,
-DeepBlue




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to