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<algogeeks%2bunsubscr...@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.