GATE Computer ScienceVery hardGATE CSE · NIELIT

A circular queue uses an array of size 8 with indices 0–7. Initially front = rear = 0. Enqueue: if (rear+1) mod 8 == front the queue is full and the operation is rejected, else rear = (rear+1) mod 8 and store. Dequeue: if front == rear it is empty and rejected, else front = (front+1) mod 8. The operations are E1 E2 E3 E4 E5 D E6 E7 E8 E9 E10 D D D E11 E12 D E13 E14 E15 E16 D (Ek enqueues item k, D dequeues). After all operations, what is the pair (front, rear)?

  1. A. (0, 5)
  2. B. (7, 6)
  3. C. (6, 4)
  4. D. (7, 5)

Correct answer: D. (7, 5)

Simulating the 23 operations (3 rejected as full or empty) leaves front = 7, rear = 5 and 6 items queued.

More Programming and Data Structures (GATE) questions

Exams that ask this topic