Question: Draw the resulting linked lists by walking through the code: I want to see that you understand how the nodes are connected and manipulated, so
Draw the resulting linked lists by walking through the code:
I want to see that you understand how the nodes are connected and manipulated, so draw some representation of a node that tells me whats in it and what it points/connects to. You can type this or draw it by hand.
Node myList;
Node n1 = new Node(Bob);
Node n2 = new Node(Carol);
Node n3 = new Node(Ted);
Node n4 = new Node(Alice);
myList = n1;
n1.setNext(n2);
n2.setNext(n3);
n3.setNext(n4); myList = null; // reset all other nodes to null as well
myList = n3;
n3.setNext(n1);
n1.setNext(n4);
n4.setNext(n2);
myList = null; // reset all other nodes to null as well
myList = n4;
n4.setNext (n2);
n2.setNext (n3);
n3.setNext (n1);
n1.setNext (n4);
DLNode newList;
DLNode n1 = new DLNode(55);
DLNode n2 = new DLNode(88);
DLNode n3 = new DLNode(15);
DLNode n4 = new DLNode(87);
newList = n1;
n1.setRight (n2);
n2.setRight (n3);
n3.setRight (n4);
n4.setLeft (n3);
n3.setLeft (n2);
n2.setLeft (n1);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
