Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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): 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started