4. How did we decide to handle the possibility of queue underflow? Group of answer choices Assume as a precondition that it will not occur. Provide an isEmpty operation so a client can prevent underflow. Ignore it. Throw a QueueUnderflowException if it occurs. Throw a QueueUnderflowException if it occurs, and provide an isEmpty operation so a client can prevent underflow.
4.
How did we decide to handle the possibility of queue underflow?
Assume you are using the text's array-based queue and have just instantiated a queue of capacity 10. You enqueue 5 elements and then dequeue 2 elements. Which indices of the internal array elements hold the remaining elements?
Suppose you start with an empty queue and perform the following operations: enqueue 1, enqueue 2, dequeue, enqueue 3, enqueue 4, dequeue, enqueue 5. What are the resultant contents of the queue, from front to back?
The text's approach to creating an array-based queue implementation is:
The following sequence of operations essentially leaves a queue unchanged.
Recall that within the ArrayBoundedQueue the front variable and the rear variable hold the indices of the elements array where the current front and rear elements, respectively, of the queue are stored. Which of the following code sequences could be used to correctly enqueue element into the queue, assuming that enqueue is called on a non-full queue and that the code also correctly increments numElements?
Assume you are using the text's array-based queue and have just instantiated a queue of capacity 10. You enqueue 5 elements, dequeue 5 elements, and then enqueue 1 more element. Which index of the internal array elements holds the value of that last element you enqueued?
Trending now
This is a popular solution!
Step by step
Solved in 5 steps