Re: [algogeeks] find out the mid point of a single linked list
maintain two pointer 1) slow pointer : it will point to next node for each iteration (ie node=node->next) 2) fast pointer : it will point to two ahead node for each iteration ( ie node=node->next->next) when fast pointer reaches the end of linked list (NULL), slow pionter will point to middle of the linked list -- Prashant Kulkarni On Tue, Sep 28, 2010 at 10:54 PM, Divesh Dixit < dixit.coolfrog.div...@gmail.com> wrote: > Given a singly-linked, find out (just give the basic logic) the mid > point of a single linked list in a single parse of the list. Assume > the program would be loaded in read-only memory so no manipulation of > the list is allowed. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@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 algoge...@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.
Re: [algogeeks] find out the mid point of a single linked list
Take 2 pointers at the beginning and move 1 pointer by 1 step and 2nd by 2 steps until end of listafter that position of 1st pointer will be the mid point of a singly list... On Wed, Sep 29, 2010 at 1:24 AM, Divesh Dixit < dixit.coolfrog.div...@gmail.com> wrote: > Given a singly-linked, find out (just give the basic logic) the mid > point of a single linked list in a single parse of the list. Assume > the program would be loaded in read-only memory so no manipulation of > the list is allowed. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@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 algoge...@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.
[algogeeks] find out the mid point of a single linked list
Given a singly-linked, find out (just give the basic logic) the mid point of a single linked list in a single parse of the list. Assume the program would be loaded in read-only memory so no manipulation of the list is allowed. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@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.