Find middle node/element of a LinkedList in Java in one pass.

Write a program to find/print middle element of a Linked list in Java in one pass.


1)      Initialize 2 pointers called fast and slow with header element. Move slow pointer by one element and fast pointer by two elements

2)      Once the fast pointer reaches end, then slow pointer will reach middle of a linked list. 



Posted in data-structures and tagged , , .

Leave a Reply

Your email address will not be published. Required fields are marked *