Programming and Data Structures · Stacks and Queues · 2 marks · Multiple choice
A circular queue stores at most n−1 items in an n-element array. REAR and FRONT index insertion/deletion positions and both start zero. Identify full and empty tests.
Full: (REAR+1) mod n == FRONT; empty: REAR == FRONT
Full: (REAR+1) mod n == FRONT; empty: (FRONT+1) mod n == REAR
Full: REAR == FRONT; empty: (REAR+1) mod n == FRONT
Full: (FRONT+1) mod n == REAR; empty: REAR == FRONT
Correct answer: (A) Full: (REAR+1) mod n == FRONT; empty: REAR == FRONT
Explanation
One slot is deliberately unused to distinguish full from empty. Empty has matching indices. Full occurs when advancing REAR one position would reach FRONT and consume that reserved slot. Therefore full is (REAR+1) mod n==FRONT and empty is REAR==FRONT, A.
More Stacks and Queues questions
GATE 2013 CS (CS1) Q54– Along with Enqueue/Dequeue, a queue supports MultiDequeue(Q), which sets m=k and…