Problem:

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
    • 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 book's 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.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.