Data Structures & AlgorithmsModerateGATE CSE

A circular queue is kept in an array of size 7. The front index is 5 and the queue currently holds 4 elements. At which index will the next element be inserted?

  1. A. 9
  2. B. 1
  3. C. 2
  4. D. 3

Correct answer: C. 2

Next free slot = (front + count) mod size = (5 + 4) mod 7 = 2.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic