UGC NET CS 2023Data Structures and Algorithms › Data StructuresVerified
UGC NET CS 2023 PYQ: Suppose a circular queue of capacity ( $\mathrm{n}-1)$ elements is implemented with an array of $\mathrm{n}$…
Suppose a circular queue of capacity ( $\mathrm{n}-1)$ elements is implemented with an array of $\mathrm{n}$ elements. Assume that the insertion and deletion operations are carried out using REAR and FRONT as array index variable respectively. Initially,
$\mathrm{REAR}=\mathrm{FRONT}=0$. The conditions to detect queue empty and queue full are
A. EMPTY: REAR ==F R O N T
FULL : $($ REAR+1) $\bmod \text{n}==$ FRONT
B. EMPTY: $($ FRONT +1$) \bmod \text{n}==$ REAR
FULL: REAR+1 $\bmod \mathrm{n}==$FRONT
C. EMPTY REAR+1) $\bmod \text{n}$==FRONT
FULL: REAR $==$ FRONT
D. EMPTY: REAR== FRONT
FULL: $($ FRONT+1) $\bmod \text{n}==$ REAR
$\mathrm{REAR}=\mathrm{FRONT}=0$. The conditions to detect queue empty and queue full are
A. EMPTY: REAR ==F R O N T
FULL : $($ REAR+1) $\bmod \text{n}==$ FRONT
B. EMPTY: $($ FRONT +1$) \bmod \text{n}==$ REAR
FULL: REAR+1 $\bmod \mathrm{n}==$FRONT
C. EMPTY REAR+1) $\bmod \text{n}$==FRONT
FULL: REAR $==$ FRONT
D. EMPTY: REAR== FRONT
FULL: $($ FRONT+1) $\bmod \text{n}==$ REAR
- AEMPTY: REAR ==F R O N T FULL : $($ REAR+1) $\bmod \text{n}==$ FRONTCorrect answer
- BEMPTY: $($ FRONT +1 $) \bmod \text{n}==$ REAR FULL: REAR+ 1 $\bmod \mathrm{n}==$ FRONT
- CEMPTY REAR+ 1 ) $\bmod \text{n}$ ==FRONT FULL: REAR $==$ FRONT
- DEMPTY: REAR== FRONT FULL: $($ FRONT+1) $\bmod \text{n}==$ REAR
Answer
(A) EMPTY: REAR ==F R O N T FULL : $($ REAR+1) $\bmod \text{n}==$ FRONT
Approach
Use the one-empty-slot convention for a circular queue in an array of n cells.
Reviewed by UGC IQ Editorial Team.