Data Structures & AlgorithmsModerateCognizant · Capgemini pattern

A circular queue is implemented in an array of size 10 and one slot is always kept empty so that 'full' and 'empty' can be told apart. How many elements can the queue hold at most?

  1. A. 10
  2. B. 11
  3. C. 5
  4. D. 9

Correct answer: D. 9

With front == rear meaning empty, 'full' is defined as (rear + 1) mod N == front, so one slot stays unused and the capacity is N − 1 = 9.

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

Exams that ask this topic