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
Post a Comment