Part 1:
Take 2 pointers moving at different speed...

1st with head->next
2nd with head->next->next

when 2nd will reach the end 1st will be pointing middle... so one result is
obtained

Part 2:
when 1st result is obtained then start with the node pointed by 1st as it
will be on 1/2th part of the list.... Start 2 pointers again

3rd with head->next
4th with head->next->next

when 4th will reach end point then 3rd will be pointing the node present at
3/4th of the list....







On Tue, Jul 19, 2011 at 3:54 PM, surender sanke <[email protected]> wrote:

> take two ptrs ptr1 and ptr2 pointing to head
> move ptr1 until 1/4th of size of list.
> move ptr1 and ptr2 until ptr1=null
> ptr2 is pointing at 3/4th
>
> surender
>
> On Tue, Jul 19, 2011 at 3:42 PM, SAMMM <[email protected]> wrote:
>
>> Yaa this will work , you need to handle the case for odd number of
>> nodes .
>> For even number of node it will serve the purpose .
>>
>> Yaa for the second part also you can use the ratio concept
>>
>> fast pointer : slow pointer = 4:3
>>
>> slow = ptr->next->next->next
>> fast = ptr->next->next->next->next
>>
>>
>> Here also we need to handle the case if the number of node is not a
>> multiple of 4 .
>>
>> --
>> 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