Question: A deque is a double-ended queue. You can insert items at either end and delete them from either end. The methods might be called insertFront()

A deque is a double-ended queue. You can insert items at either end and delete them from either end. The methods might be called insertFront() and insertRear(), and removeFront() and removeRear(). A deque provides a more versatile data structure than either a stack or a queue.

If you restrict yourself to insertFront() and removeFront() (or their equivalents on the insertRear() and removeRear()), the deque acts like a stack. If you restrict yourself to insertRear() and removeFront() (or the opposite pair), it acts like a queue.

In this project, you are required to program for two files.

The first is Deque.java that is the class definition (Listing 4.4), which should include the following methods. Deque need to support wraparound at the end of the array, as queues do

-insertFront(), removeFront(): insert and remove element into the Deque o -insertRear(), removeRear(): insert and remove element into the Deque -isEmpty(): if the Deque is empty -isFull(): if the Dqeue is full -size(): return the number of items in queue. -display(): display all the element from Front to Rear. (Hint: You could use books code insert() as insertRear(), remove as removeFront(), then to write the similar methods for insertFront() and removeRear(), which both index are decreasing.)

The second file is DequeApp.java that is the application to use Deque ADT. You are required to have three objects to show your deque ADT used as a stack, queue, and deque.

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!