Question: For this question, a circular array is used to implement a queue. You must implement a special method dequeue that takes one parameter an integer)

 For this question, a circular array is used to implement a

For this question, a circular array is used to implement a queue. You must implement a special method dequeue that takes one parameter an integer) specifying how many elements need to be removed from the queue. The method dequeue returns a reference to a list containing all the elements that have been removed, in reverse of order of removal. For this question, you are allowed to use the predefined class LinkedList. In particular, it has a constructor LinkedList(), stores an arbitrarily large number of elements, and implements the following methods. public interface List{//Add the element at the specified position of the list public abstract boolean add (int pos, E o);//Returns the element at the specified position in this list. public abstract E get (int index)://Returns the number of elements in this list public abstract int size();} bullet For your implementation of the method dequeue, you cannot use the methods of the class CircularQueue, accordingly these methods are not shown on the next page. Your code needs to manipulate directly the instance variables, elems, front, rear, and size. The execution of the Java program below displays "[2, 1, 0]". CircularQueue q; q = new CircularQueue(100); for (int i=0; i 1; 1 = q.dequeue(3); System. out. print ("["): for (int 1=0: i0) {System. out. print (", ");} System. out. print (1. get (i));} System. out. println ("]")

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!