Answered step by step
Verified Expert Solution
Question
1 Approved Answer
class EmptyListE extends Exception{} public class DoublyLinkedList { private NodeDL head; private NodeDL tail; private int size; // TODO: default constructor public DoublyLinkedList(){ } //
class EmptyListE extends Exception{} public class DoublyLinkedList{ private NodeDL head; private NodeDL tail; private int size; // TODO: default constructor public DoublyLinkedList(){ } // TODO: secondary constructor public DoublyLinkedList(NodeDL head, NodeDL tail){ } public int size() { return this.size; } // TODO: Insert elem at the start of the DoublyLinkedList void insertAtHead(E elem){ } // TODO: Insert elem at the end of the DoublyLinkedList void insertAtTail(E elem){ } // TODO: Delete the element from the start of the DoublyLinkedList. Throw an EmptyListE if there's nothing to delete E deleteAtHead() throws EmptyListE{ return null; } // TODO: Delete the element from the end of the DoublyLinkedList. Throw an EmptyListE if there's nothing to delete E deleteAtTail() throws EmptyListE{ return null; } // TODO: Get the element at some position. If it's not possible, throw an IndexOutOfBoundsException E get (int index) throws IndexOutOfBoundsException{ return null; } // TODO: Search the DoublyLinkedList for elem. If not found, return -1; public int search(E elem){ return -1; } // TODO: When passed some object, return true if it's a DoublyLinkedList, has the same elements in the same order. public boolean equals(Object o){ return false; } public String toString(){ String ret = ""; NodeDL temp = head; for(int i = 0; i < size; i++){ ret += temp.data + " "; temp = temp.next; } return ret; } }
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