Question discussion

A circular queue of size 6 uses indices 0 to 5. The front index is 4 and the rear index (the index of the last element) is 1. How many elem…

1175Medium DSSSB TGT Computer Science 0 replies 1 views
0

A circular queue of size 6 uses indices 0 to 5. The front index is 4 and the rear index (the index of the last element) is 1. How many elements are in the queue?

  • A3
  • B4
  • C5
  • D2
Correct answer: B

Explanation

The elements occupy indices 4, 5, 0 and 1, i.e. (rear − front + size) mod size + 1 = (1 − 4 + 6) mod 6 + 1 = 4.

Discussion 0

Nobody has replied yet. Start the discussion!