Question
Hello, I am taking a Data Structures and Algorithms class in Java and we were just introduced to Stacks and Queues. In the first part
Hello,
I am taking a Data Structures and Algorithms class in Java and we were just introduced to Stacks and Queues. In the first part of the assignment we are asked to create a Deque which I do not really know how to implement. I have attached the description of the problem and a note from the instructor. Also, comments would be appreciated!
Thanks!
Note from Instructor:
Your class Deque in Assignment 2 should look like this:
class Deque
{
private int maxSize;
private long[] dekArray;
private int left;
private int right;
private int nItems;
//--------------------------------------------------------------
public Deque(int s) // constructor
{
maxSize = s;
dekArray = new long[maxSize];
int center = maxSize/2 - 1;
left = center+1; // left and right
right = center; // start out "crossed"
nItems = 0;
}
// other methods
}
Create a Deque class based on the discussion of deques (double-ended queues). It should include insertLeft (),insertRight ),removeLeft ), removeRight ), peekRighto, peekLeft ), isEmpty (),andisFull ) methods. It will need to support wraparound at the end of the array, as queues do. Write a driver class Deque App to test class Deque 1. eektleft 0): 1sss Desauichs.teStep 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