public static void main(String args[]){
        MiddleElementOfLinkList mle = new MiddleElementOfLinkList();
        LinkList ll = new LinkList();
        Node head = null;
        head = ll.addNode(1, head);
        System.out.println(mle.middle(head));
        head = ll.addNode(2, head);
        System.out.println(mle.middle(head));
        head = ll.addNode(3, head);
        System.out.println(mle.middle(head));
        head = ll.addNode(4, head);
        System.out.println(mle.middle(head));
        head = ll.addNode(5, head);
        System.out.println(mle.middle(head));
    }
Find middle element in linklist.
Use two pointer approach.
Test cases
0,1,2,3,4 and so on nodes
@author tusroy
src/com/interview/linklist/MiddleElementOfLinkList.java