Question: 3.2 Doubly-Linked Lists Recall our implementation of a doubly-linked list (DLList): protected class Nodef Node next, prev; public class DLList extends AbstractSequentialList protected Node dummy;

 3.2 Doubly-Linked Lists Recall our implementation of a doubly-linked list (DLList):

3.2 Doubly-Linked Lists Recall our implementation of a doubly-linked list (DLList): protected class Nodef Node next, prev; public class DLList extends AbstractSequentialList protected Node dummy; protected int n; 1. 2. Explain the role of the dummy node. In particular, what are dummy.next and dummy.prev? One of the following two functions correctly adds a node u before the node p in the DLList, the other one is incorrect. Which one is correct? protected Node add (Node u, Node p) f u. next = p; u.pre p.prev u.next.prev-u; u . prev. next = u ; nt+; return u; protected Node add (Node u, Node p) f u . next = p; u . next . prev = u; u.prev.next-u; return u; 3. What is the running-time of add(i,x) and remove(i) in a DLList

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!