Write an enqueue method for a queue implemented as a circular array. You may assume that you have access to a method called expandCapacity that will double the size of the array if necessary. The class has instance variables front and rear, which represent the indexes of the front and rear of the queue. It also has an integer variable called count that represents the number of elements in the queue, as well as an array of generic T types called queue that represents the queue.
What will be an ideal response?
```
public void enqueue(T element) {
if(count == queue.length)
expandCapacity();
queue[rear] = element;
rear = (rear+1)%queue.length;
count++;
}
```
Computer Science & Information Technology
You might also like to view...
Which fields are listed in the Create Source dialog box are determined by the ________ selected by the user
Fill in the blank(s) with correct word
Computer Science & Information Technology
The following sentence is punctuated correctly. Fred is a beagle with brown and white markings, and Copper is a yellow Labrador retriever.?
Answer the following statement true (T) or false (F)
Computer Science & Information Technology