Recall that within the ArrayBoundedQueue (implemented with the floating-front) 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? Question 1 options: rear++; elements[rear] = element; front++; elements[front] = element; rear = (rear + 1) % elements.length; elements[rear] = element; front = (front + 1) % elements.length; elements[front] = element; None of these is correct.
Recall that within the ArrayBoundedQueue (implemented with the floating-front) 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?
Question 1 options:
rear++; elements[rear] = element;
front++; elements[front] = element;
rear = (rear + 1) % elements.length; elements[rear] = element;
front = (front + 1) % elements.length; elements[front] = element;
None of these is correct.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps