Question: Consider this variation on the DoublyLinkedList implementation from class. public class DoublyLinkedList private Node head, tail; private static class Node public Node prev, next; public
Consider this variation on the DoublyLinkedList implementation from class. public class DoublyLinkedList private Node head, tail; private static class Node public Node prev, next; public String data; public Node(Node prev, String data, N ode next) ( this . prev = prev; this.next next; this.data data; public DoublyLinkedList) head tail = null; * Add data to the end (tail) of the Dou blyLinkedList public void add(String data) if (tail-null) { head tail new Node(null, data, null) else t assert ( tail.next null); tail.next nev. Node (tail, data, nu tail tail.next; s Retrieve an element from the middle o f the list s Eparam i Zero-based index of the elen ent to retrieve * @return The element (TBD: what to do if i is invalid) public String get int i) Node current head; for (int j 0; j
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
