in hair and tortoise this they will meet wen 1st pointer(tortoise) is at the
end of the linked list(in 1st traverse) and 2nd pointer( hair) reaches the
same node 2nd time. That means u traversed the list twice.
Its better that since u hv the head of the linked list,  keep on moving till
the end .If next of end is head then its circular.
Rather for queue, u hv track of both front and rear, so just check if
rear->next ==front. One line code.
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Fri, Sep 23, 2011 at 8:13 AM, Aditya Virmani <virmanisadi...@gmail.com>wrote:

> in arrays i guess it can be simply analysed checking the last element of
> array(which can be obtained by sizeof) & checking how the entries are filled
> inn the array...
> in linked list hair & tortoise rule...initialize two pointers...one's step
> size:1, second's step size two... & run through the linked list, if they
> meet newhere ...it contains a loop or circular list.
>
>
> On Thu, Sep 22, 2011 at 10:51 PM, sukran dhawan <sukrandha...@gmail.com>wrote:
>
>> use hair and tortoise rule for lists
>> i don think we can do it for arrays
>>
>>
>> On Thu, Sep 22, 2011 at 10:22 PM, Ishan Aggarwal <
>> ishan.aggarwal.1...@gmail.com> wrote:
>>
>>> In both the cases... what would be the condition?
>>>
>>>
>>> On Thu, Sep 22, 2011 at 10:19 PM, sukran dhawan 
>>> <sukrandha...@gmail.com>wrote:
>>>
>>>> queue represnted as array or linked list ?
>>>>
>>>>
>>>> On Thu, Sep 22, 2011 at 10:08 PM, Ishan Aggarwal <
>>>> ishan.aggarwal.1...@gmail.com> wrote:
>>>>
>>>>> How will u detect if a queue is circular or not??
>>>>>
>>>>> --
>>>>> Kind Regards
>>>>> Ishan Aggarwal
>>>>> [image: Aricent Group]
>>>>> Presidency Tower-A, M.G.Road,Sector-14
>>>>> Gurgaon,Haryana.122015 INDIA
>>>>> Phone : +91-9654602663
>>>>> ishan2.aggar...@aricent.com <puneet.ar...@aricent.com>
>>>>>
>>>>>  --
>>>>> 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.
>>>>
>>>
>>>
>>>
>>> --
>>> Kind Regards
>>> Ishan Aggarwal
>>> [image: Aricent Group]
>>> Presidency Tower-A, M.G.Road,Sector-14
>>> Gurgaon,Haryana.122015 INDIA
>>> Phone : +91-9654602663
>>> ishan2.aggar...@aricent.com <puneet.ar...@aricent.com>
>>>
>>>  --
>>> 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