Question: You are NOT allowed to use JAVA API Container classes!!!! READ before coding!!! Implement a generic Deque ( double ended queue ) based on a
You are NOT allowed to use JAVA API Container classes!!!! READ before coding!!!
Implement a generic Deque double ended queue based on a DoublyLinkedList. Deque is an ADT that allows use to add or remove element from either the front or the back of the Deque. Implement the following methods to your MyDeque class; insert element at back, insert element at front, remove last element, remove first element. Both remove methods should return the element being removed. Size is NOT an attribute of this class. Use the given generic Node class that allows you to build the DoublyLinkedList for MyDeque, and test your MyDeque with the given main method. All classes must be in a single Java program called MyDeque.java.
Copy and paste the code below on to a program named MyDeque.java. Write the methods, paste output on the bottom of the source program, finally attach the program to this question. Do not change the Node class or the main method.
public class MyDeque
implement the rest of the code.
class Node
E element;
Node prev;
Node next;
public NodeE e element e;
public static void mainString args
MyDeque dq new MyDeque;
System.out.printlnRemoving back value dqremoveBack;
System.out.printlnRemoving front value dqremoveFront;
dqinsertBack;
dqinsertBack;
System.out.printlnRemoving front value dqremoveFront;
dqinsertBack;
dqinsertFront;
dqinsertFront;
System.out.printlnRemoving front value dqremoveFront;
System.out.printlnRemoving Back value dqremoveBack;
System.out.printlnRemoving front value dqremoveFront;
System.out.printlnRemoving Back value dqremoveBack;
System.out.printlnRemoving Back value dqremoveBack;
System.out.printlnRemoving front value dqremoveFront;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
