Question:

In a circular queue implemented using an array of size $MAX$, if 'front' and 'rear' are the indices, the condition for the queue being full is:

Show Hint

To remember this: The condition for an empty queue is $front == -1$ (or $front == rear$ in some variations), while the condition for a full queue involves the "wrap-around" logic of the modulo operator.
Updated On: Jul 4, 2026
  • $(rear + 1) \% MAX == front$
  • $rear == MAX - 1$
  • $front == (rear + 1)$
  • $front == 0 \ \&\& \ rear == MAX$
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

Concept: A circular queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is connected back to the first position to make a circle.
Modulo Arithmetic: Used to wrap indices back to 0 when they reach the end of the array.
Space Management: A circular queue solves the "waste of space" problem in a standard linear array-based queue.

Step 1:
Understanding the indices.
In a circular queue:
Front: Points to the element to be removed.
Rear: Points to the last element inserted.

Step 2:
Defining the "Next" position.
The next position after rear is calculated as $(rear + 1) \% MAX$. This ensures that if $rear$ is at the last index ($MAX-1$), the next index becomes 0.

Step 3:
Determining the Full condition.
The queue is considered full when the "next" position of $rear$ would collide with $front$. In many implementations, one slot is intentionally left empty to distinguish between a "Full" and "Empty" queue. Thus, the standard condition is $(rear + 1) \% MAX == front$.
Was this answer helpful?
0
0