simple way of understanding this algo is that , q is incremented twice than
p or you can say q is moving twice faster then p.

consider a scenario where last_node-> = first_node.

now q would complete 2 round of this single link before node p reaches
last_node . so when p reaches last_node , at that point of time q would
have reached last_node (hence completing this 2 circle).

hope this will help you in understanding the idea.

On Fri, Dec 2, 2011 at 12:14 PM, Vijay Khandar <[email protected]>wrote:

> But how plz explain in detail..............
>
>
> On Thu, Dec 1, 2011 at 8:14 PM, Karthikeyan V.B <[email protected]>wrote:
>
>> detects the loop in the linked list
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to