<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/* Time spent on a2:  hh hours and mm minutes.

 * Name:
 * Netid: 
 * What I thought about this assignment:
 *
 *
 */

/** An instance is a doubly linked list. */
public class LinkedList&lt;E&gt; {
    private int size;  // Number of values in the linked list.
    private Node first; // first node of linked list (null if none)
    private Node last; // last node of linked list (null if none)

    /** Constructor: an empty linked list. */
    public LinkedList() {
    }

    /** Return the number of values in this list. */
    public int size() {
        return size;
    }

    /** Return the first node of the list (null if the list is empty). */
    public Node getFirst() {

        return first;
    }

    /** Return the last node of the list (null if the list is empty). */
    public Node getLast() {
        return last;
    }

    /** Return the value of node n of this list.
     * Precondition: n is a node of this list; it may not be null. */
    public E valueOf(Node n) {
        assert n != null;
        return n.value;
    }

    /** Return a representation of this list: its values, with adjacent
     * ones separated by ", ", "(" at the beginning, and ")" at the end. &lt;br&gt;
     * 
     * E.g. for the list containing 6 3 8 in that order, the result it "(6, 3, 8)". */
    public String toString() {
        //TODO: Write this method first. Do NOT use fields size

        return "";
    }

    /** Return a representation of this list: its values in reverse, with adjacent
     * ones separated by ", ", "(" at the beginning, and ")" at the end. &lt;br&gt;
     * 
     * E.g. for the list containing 6 3 8 in that order, the result it "(8, 3, 6)".*/
    public String toStringReverse() {
        //TODO: Write this method second. Do NOT use fields size

        return "";
    }

    /** add value v in a new node at the end of the list and
     * return the new node. */
    public Node append(E v) {
        //TODO:This is the third method to write. Then you can begin testing
        // this method AND toStringand toString reverse at the same time.
        
        return null;
    }

    /** add value v in a new node at the beginning of the list and
     * return the new node */
    public Node prepend(E v) {
        //TODO: This is the fourth method to write and test
        
        return null;
    }

    /** Insert value v in a new node after node n and
     * return the new node.
     * Precondition: n must be a node of this list; it may not be null. */
    public Node insertAfter(E v, Node n) {
        //TODO: This is the fifth method to write and test
        
        return null;
    }

    /** Insert value v in a new node before node n and
     * return the new node.
     * Precondition: n must be a node of this list; it may not be null. */
    public Node insertBefore(E v, Node n) {
        //TODO: This is the sixth method to write and test
        
        return null;
    }

    /** Remove node n from this list.
     * Precondition: n must be a node of this list; it may not be null. */
    public void remove(Node n) {
        //TODO: This is the seventh method to write and test
        
    } 


    /*********************/

    /** An instance is a node of this list. */
    public class Node {
        /** Previous node on list (null if this is the first node). */
        private Node prev;

        /** The value of this element. */
        private E value; 

        /** Next node on list. (null if is the last node). */
        private Node next; 

        /** Constructor: an instance with previous node p (can be null),
         * next node n (can be null), and value v. */
        private Node(Node p, Node n, E v) {
            prev= p;
            next= n;
            value= v;
        }

        /** Return the value of this node. */
        public E getValue() {
            return value;
        }

        /** Return the node previous to this one (null if this is the
         * first node of the list). */
        public Node prev() {
            return prev;
        }

        /** Return the next node in this list (null if this is the
         * last node of this list). */
        public Node next() {
            return next;
        }
    }

}
</pre></body></html>