Complete the code to initialize the front index of the circular queue.
int front = [1];The front index is initialized to -1 to indicate the queue is empty.
Complete the condition to check if the circular queue is full.
if ((rear + 1) % size == [1]) { // Queue is full }
The queue is full when the next position of rear is front.
Fix the error in updating the rear index after enqueue operation.
rear = (rear [1] 1) % size;
We add 1 to rear and then take modulo size to move to the next position circularly.
Fill both blanks to correctly update front and rear when inserting the first element.
if (front == -1) { front = [1]; rear = [2]; }
When the queue is empty, both front and rear are set to 0 for the first element.
Fill all three blanks to correctly dequeue an element and update front index.
if (front == rear) { front = [1]; rear = [2]; } else { front = (front [3] 1) % size; }
If front equals rear, queue becomes empty after dequeue, so both set to -1. Otherwise, front moves forward by 1 modulo size.
