GATE Computer ScienceEasyGATE CS (PYQ pattern)

A circular queue of capacity 10 (array indices 0..9) keeps front and rear indices; front is the index of the first item and rear is the index of the next free slot, with one slot always kept empty. If front = 7 and rear = 3, how many items are in the queue, and how many more can be enqueued?

  1. A. 4 items and 5 more
  2. B. 6 items and 4 more
  3. C. 5 items and 4 more
  4. D. 6 items and 3 more

Correct answer: D. 6 items and 3 more

Items = (rear - front + 10) mod 10 = (3 - 7 + 10) mod 10 = 6. Capacity usable is 9, so 9 - 6 = 3 more.

More Programming and Data Structures (GATE) questions

Exams that ask this topic