Question discussion

A circular queue of capacity 8 has front = 5 and rear = 2 (0-indexed; front is the first element, rear the last, and the queue is not empty…

1510Medium DSSSB TGT Computer Science 0 replies 1 views
0

A circular queue of capacity 8 has front = 5 and rear = 2 (0-indexed; front is the first element, rear the last, and the queue is not empty). How many elements does it hold?

  • A4
  • B5
  • C6
  • D7
Correct answer: C

Explanation

The elements occupy positions 5, 6, 7, 0, 1 and 2, i.e. (2 − 5 + 8) mod 8 + 1 = 6 elements.

Discussion 0

Nobody has replied yet. Start the discussion!