Create a mirrored linked list in Java
        Posted  
        
            by glacier89
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by glacier89
        
        
        
        Published on 2010-04-15T05:04:49Z
        Indexed on 
            2010/04/15
            5:23 UTC
        
        
        Read the original article
        Hit count: 482
        
Linked-List: Mirror
Consider the following private class for a node of a singly-linked list of integers:
private class Node{
public int value;
public Node next;
}
A wrapper-class, called, ListImpl, contains a pointer, called start to the first node of a linked list of Node.
Write an instance-method for ListImpl with the signature:
public void mirror();
That makes a reversed copy of the linked-list pointed to by start and appends that copy to the end of the list. So, for example the list:
start 1 2 3
after a call to mirror, becomes:
start 1 2 3 3 2 1
Note: in your answer you do not need to dene the rest of the class for ListImpl just the mirror method.
© Stack Overflow or respective owner