WBJECA 2025 — Computer PYQ
WBJECA | Computer | 2025In a circular queue of size n, when is the queue considered full?
Choose the correct answer:
- A.
Front == Rear
- B.
(Rear + 1) % n == Front
(Correct Answer) - C.
Rear == n
- D.
Front == 0
(Rear + 1) % n == Front
Explanation
A circular queue is a linear data structure that follows the FIFO (First-In-First-Out) principle, but the last position is connected back to the first position to make a circle. This overcomes the memory wastage issues of a standard linear queue.
Circular Queue Full Condition: The queue is full when the
Rearpointer is just one position behind theFrontpointer in the circular array.The Modulo Operator: We use the modulo operator
%to handle the "wrap-around" behavior of the circular array.
The mathematical logic for the full state can be defined as:
Full Condition⟹(Rear+1)(modn)=Front
In contrast, the empty condition is generally represented as:
Empty Condition⟹Front=−1
Because the modulo operation correctly handles the wraparound case where the Rear pointer reaches the end of the array (index n−1), option (B) is the universally accepted condition for a full circular queue.
