Show transcribed image text DQuestion 1 1 pts Consider 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 this.next this.data prev; next ; data public DoublyLinkedList) head = tail null; *Add data to the end (tail) of the Dou blyLinkedList public void add(String data) f if (tail =null) { head : tail new Node( null, data, null): else ( assert ltail.next null); tail.next new Nodel tail, data, nu Ll): tail- tail.next + Retrieve an elenent from the middle o * eparan i Zero-based index of the elen * @return The elenent (TBD: what to do f the list ent to retrieve if i is invalid) public String getlint 1) Node current-head: for (int 1 i;) / Count our way up to the desired element current current.next ; return current data; What would happen if we ran the following code? You may want to try it in Eclipse.
DQuestion 1 1 pts Consider 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 this.next this.data prev; next ; data public DoublyLinkedList) head = tail null; *Add data to the end (tail) of the Dou blyLinkedList public void add(String data) f if (tail =null) { head : tail new Node( null, data, null): else ( assert ltail.next null); tail.next new Nodel tail, data, nu Ll): tail- tail.next + Retrieve an elenent from the middle o * eparan i Zero-based index of the elen * @return The elenent (TBD: what to do f the list ent to retrieve if i is invalid) public String getlint 1) Node current-head: for (int 1 i;) / Count our way up to the desired element current current.next ; return current data; What would happen if we ran the following code? You may want to try it in Eclipse.





