@Rahul:
As Dev said:
Now start the fast pointer at the head and take m single steps with both
pointers. The fast pointer is at the beginning of the cycle, and the slow
pointer has traversed the cycle (2*t  - u) times and is back at the
beginning of the cycle.

k= (2*t-u)p -m

When fast pointer is being started from the beginning, the slow pointer has
not yet completed 2*t-u round, but m nodes less. That means if fast pointer
and slow pointer both are moved m nodes further, they will meet at
the beginning of the cycle.

Following is just a reasoning why both pointer can't meet sooner than m
step:
The pointers couldn't be equal sooner since the fast pointer is not in the
cycle after less than m steps and the slow pointer is in the cycle. "


-Cheers
Moheed
"I am who I am, no matter where I am or who I am with."
*
*



On Sat, Mar 10, 2012 at 4:02 PM, rahul sharma <rahul23111...@gmail.com>wrote:

> 1-2-3-4-5-6-7-8-9-10-11
> fast and slow meet at 11
>
> m=6;
> k=4
>
>
> ...i cant get last two lines....when k= sometimes around the circle -
> m......
>
> then after that taking fast at begining and slow within circle ..i cant
> get this...@ dave plz explain with this example...will b of gr8
> help..thnx in advance..
>
>
> On Sat, Mar 10, 2012 at 3:02 PM, Kumar Vishal <kumar...@gmail.com> wrote:
>
>> Hi
>> On Mar 9, 2012 3:48 PM, "rahul sharma" <rahul23111...@gmail.com> wrote:
>>
>>>  i have 2 pointers fast and slow.....now if tehy meet there is a loop...
>>>
>>> now keep one ptr at meeting point and take other one to the begining of
>>> list....move both at speed of one..they will meet at start of loop....how
>>> this happens???why they meet at start..plz tell logic behind this???thnx in
>>> advance
>>>
>>> --
>>> 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
>>> algogeeks+unsubscr...@googlegroups.com.
>>> 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 algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> 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 algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> 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 algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to