Suppose a circular queue of capacity $(\mathrm{n}-1)$ elements is implemented with an array of n elements. Assume that the insertion and deletion operations are carried out using REAR and FRONT as array index variables, respectively. Initially, REAR $=F R O N T=0$. The conditions to detect queue full and queue empty are
A. Full: $($ REAR +1$) \bmod n=$ FRONT, empty: REAR $==$ FRONT
B. Full: $($ REAR +1$) \bmod n=F R O N T$, empty: $(F R O N T+1) \bmod n==$ REAR
C. Full: REAR $=$ FRONT, empty: $($ REAR +1$) \bmod n==$ FRONT
D. Full: $($ FRONT +1$) \bmod n=$ REAR, empty: REAR $==$ FRONT
implement, this circular queue is 5 , which is n .
In the beginning when the queue is empty, FRONT and REAR point to 0 index in the array. REAR represents insertion at the REAR index. FRONT represents deletion from the FRONT index.
$$
\begin{aligned}
& \text { enqueue ("a"); REAR }=(\text { REAR }+1) \text { \% } ;(\text { ERONT }=0, \text { REAR }=1) \\
& \text { enqueue }(" \mathrm{~b} ") \text {; REAR }=(\operatorname{REAR}+1)=5 ;(\text { FRONT }=0, \text { REAR }-2) \\
& \text { enquetue ("c"); RENR }=(\text { RENR }+1) \text { s5; ( FRONT }=0, \text { REMR }=3 \text { ) } \\
& \text { enqueue }(" \mathrm{~d} \text { "); REAR }=(\text { REAR }+1) \text { 85; ( FRONT }=0, \text { REAR }=4)
\end{aligned}
$$
Now, the queue size is 4 , which is equal to the maxQueueSize. Hence, the overflow condition is reached.
Now, we can check for the conditions.
When Queue Full:
```
(REAR+1) &n - (4+1) &5 - 0
FRONT is also 0.
Hence (REAR + 1) in is equal to the FRONT.
When Queue Empty:
REAR was equal to ERONT when empty (because in the starting,
before filling the queve FRONT - REAR - 0)
Hence Option A is correct.
```