[algogeeks] find out the mid point of a single linked list

2010-09-28 Thread Divesh Dixit
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

Re: [algogeeks] find out the mid point of a single linked list

2010-09-28 Thread Prashant Kulkarni
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