Well the creator of programming languages were smart enuf to give loops for that.:)
On Tue, Jul 19, 2011 at 4:31 PM, Yogesh Yadav <medu...@gmail.com> wrote: > @Manikanta : > > assume we have to find 5/60th part of node then > > we will take a pointer moving with 5 nodes at a time and 2nd with 60 nodes > at a time... > > for pointer with 60 nodes at a time we have to check(head->next!=null) then > (head->next->next!=null).... upto 60 nodes... > > Don't you think coding part will become much more complicated... > > > > > On Tue, Jul 19, 2011 at 4:23 PM, Manikanta Babu <manikantabab...@gmail.com > > wrote: > >> Take two pointers ptr1 and ptr2, >> >> ptr1 should move 4 nodes at a time >> ptr2 should move 3 nodes at a time, >> thats it when the ptr1 reaches the end the ptr2 will be pointing to 3/4th, >> same way for m/n th node. But this works best for even number of nodes in >> list. >> >> For odd numbers we need to compromise like finding the middle node :) >> >> Cheers, >> Mani >> >> On Tue, Jul 19, 2011 at 4:20 PM, Yogesh Yadav <medu...@gmail.com> wrote: >> >>> 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 <surend...@gmail.com>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 <somnath.nit...@gmail.com>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 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. >>> >> >> >> >> -- >> Thanks & Regards, >> Mani >> http://www.sanidapa.com - The music Search engine >> >> -- >> 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. > -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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.