data structures - How to Find a middle element in a link list without traversing the entire list? -


how find middle element in link list without traversing entire list . ? ...and @ maximum can use 2 pointers...how ? .... , length of list not given.

i don't see how without traversing entire list unless know length.

i'm guessing answer wants 1 pointer traversing 1 element @ time, while second pointer moves 2 elements @ time.
way when second pointer reaches end, first pointer @ middle.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -