Question: In Java Please Implement a class Deque (pronounced deck) for building doubly-linked lists. The class should have a nested class inside it, DoubleNode , where
In Java Please
Implement a class Deque (pronounced "deck") for building doubly-linked lists. The class should have a nested class inside it, DoubleNode, where each node contains a reference to the item preceding it and the item following it in the list (null if there is no such item). Then implement methods for the following tasks:
- Insert at the beginning
- Insert at the end
- Remove from the beginning
- Remove from the end
- Insert before a given node
- Insert after a given node
- Remove a given node
- Move to front (move an object to the front)
- Move to end (move an object to the end)
Your Deque should be able to store any type of object. See the textbook on how to use Java generics.
Your methods should use these names and return types. T, below, is a placeholder type used to stand in for whatever actual type the client code wants to store in your collection.
public void insertAtBeginning(T value) public void insertAtEnd(T value) public T removeFromBeginning() public T removeFromEnd() public void insertBefore(T value, DoubleNode node) public void insertAfter(T value, DoubleNode node) public void remove(DoubleNode node) public void moveToFront(DoubleNode node) public void moveToEnd(DoubleNode node)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
