Question: Question 4 20 pts Consider a slight variation on the queue. In this version new items can be added to and removed from either end.

 Question 4 20 pts Consider a slight variation on the queue.

Question 4 20 pts Consider a slight variation on the queue. In this version new items can be added to and removed from either end. This data structure is commonly called a doubly-ended queue, or deque. Implement one method of each type, i.e. one insert" and one remove". given in the Deque class. You may assume the DequeException class has been defined for you. Hint: remember to handle all of the special cases! public class Deque { private class Node { private Node (T data) { this data = data; private I data; private Node]> next; private. Node prev; public void insertAtHead(E data) public void insertAttail(E data) {n} public E removeFromHead() throws Dequekeption {} public E removeFromTail() throws DequeException {m} private Node head; private Node tail; REMEMBER! ONLY IMPLEMENT (insertAt Head AND removeFromHead) OR (insertAtTail AND removeFromTail). You are implementing 1 insert and 1 remove methods for 2 methods total, NOT 4 METHODS! The "remove" methods should throw a DequeException when the Deque is empty. Edit Format Table 12pt v Paragranh D

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!