The implementation of ArrayQueue.clear() is simple to write and test, but it is inefficient because of the method calls to dequeue(). Provide an alternative implementation that clears the array directly. Perform timing measurements to see what the improvement in speed is.
What will be an ideal response?
```
/**
* Empty the queue of elements
*/
public void clear() {
// set each array cell to null
for (int i = 0; i < this.size; i++)
this.queue[i] = null;
// reset fields
this.front = 0;
this.rear = 0;
this.size = 0;
}
```
You might also like to view...
The numbers 3, 2, 5, 7 are enqueued in a queue in that order, then three numbers are dequeued, and finally 3, 7, 9, 4 are enqueued in that order. What is the first number in the queue (the next number to be dequeued)?
a. 3 b. 7 c. 9 d. 4
What is the output of the following code:
``` double x = 5.5; int y = (int)x; System.out.println("x is " + x + " and y is " + y); ``` a. x is 5 and y is 6 b. x is 6.0 and y is 6.0 c. x is 6 and y is 6 d. x is 5.5 and y is 5 e. x is 5.5 and y is 5.0
When it is not clear which chart type is best for the selected data, select ________ from the Charts group on the Insert tab
Fill in the blank(s) with the appropriate word(s).
In designing a storage subsystem, you must keep in mind that you may need network connectivity
Indicate whether the statement is true or false