Take out a piece of paper. We’ll be programming on paper.
public class DLinkedList<E> implements List211<E> {
/** Holds the head of the list. */
private DLinkedNode head;
/** The size of the list. */
private int size;
/**
* Inserts the specified element at the specified position in this list. Shifts the element currently at that
* position (if any) and any subsequent elements to the right (adds one to their indices).
* @param index index at which the specified element is to be inserted
* @param element element to be inserted
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index > size())
*/
/** Doubly linked node. */
private class DLinkedNode {
E data;
DLinkedNode next;
DLinkedNode prev;
}
}Answer the following questions:
What is the Big-O of the add(E item) method? Why?
What is the Big-O of the remove(int index) method? Why?