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
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