Write code for Dequeue data structure in Java language. Dequeue is a special kind of a Queue where additions and deletions can be done at both ends. You are to implement Dequeue using a circular array.
Dequeue has instance variables front, rear and elements (the array that holds the elements of the Dequeue). Go over the circular array implementation of Queue given in your book. Recall that, for an empty Queue rear is one-position counter clockwise to front and unfortunately, the same configuration holds for a full queue. To distinguish between a full-queue and an empty queue, we could keep track of the number of elements in count instance variable. (if count == 0, the queue is empty, and if count == elements.length, queue is full). In our implementation of Dequeue, there is no count variable to keep track of the number of elements. Instead, to distinguish a full-queue from an empty queue, we never allow the queue to get completely full. A full queue is one with exactly one empty spot in the array. That way we can distinguish an empty queue and full queue by looking at the relative positions of front and rear. When Dequeue is created, it starts off with an array of 5 elements. :Java may not compute the % of a negative number correctly. Be aware of this when coding.