Assume the following method is added to the ArrayQueue class. What does this method do? public void undefined() { if(size < 2) return; if(size == capacity) reallocate(); rear = (rear + 1)%capacity; int f = (front + 1)%capacity; theData[rear] = theData[f]; size++; } Makes the front as rear and the rear as front, if the number of elements in the queue is at least 2. Adds the front element of the queue at the rear of the queue, if the number of elements in the queue is at least 2. Adds the second element of the queue at the rear of the queue, if the number of elements in the queue is at least 2. Exchanges the first and the last elements of the queue, if the number of elements in the queue is at least 2.
Assume the following method is added to the ArrayQueue class. What does this method do?
public void undefined()
{
if(size < 2) return;
if(size == capacity)
reallocate();
rear = (rear + 1)%capacity;
int f = (front + 1)%capacity;
theData[rear] = theData[f];
size++;
}
-
Makes the front as rear and the rear as front, if the number of elements in the queue is at least 2.
-
Adds the front element of the queue at the rear of the queue, if the number of elements in the queue is at least 2.
-
Adds the second element of the queue at the rear of the queue, if the number of elements in the queue is at least 2.
-
Exchanges the first and the last elements of the queue, if the number of elements in the queue is at least 2.
Step by step
Solved in 2 steps