Stacks & Queues

Your answer
Answer & solution
Official answer: A
With one of n slots deliberately unused, equal FRONT and REAR denotes the initial empty queue and all subsequent empty states. The queue is full when advancing REAR by one modulo n would collide with FRONT: (REAR+1) mod n=FRONT. These conditions permit n−1 stored elements and distinguish empty from full. Hence A.
Check: For example, with n=4 the usable capacity is three. Starting at FRONT=REAR=0, three insertions advance REAR to 3; its next value would be 0, equal to FRONT, so the full test succeeds without confusing it with the empty state.