Machine-translated by Google. Questions are authored in English.
Top

Queues Questions and Answers

11.

If a queue is implemented by a circular array QUEUE [0..14]. The number of elements in the queue if FRONT = 11 and REAR = 4 will be

Exam Year(s)

Tripura Public Service Commission - 2026,

Answer: D

The queue holds 8 elements.

QUEUE [0..14] has 15 slots. When REAR has wrapped round past the end of the array and is now less than FRONT, the count is found by adding the array size before taking the difference.

\[ \begin{aligned} \text{count} &= (\text{REAR} - \text{FRONT} + N) \bmod N \\ &= (4 - 11 + 15) \bmod 15 \\ &= 8 \end{aligned} \]

Counting slots directly gives the same answer: positions 11, 12, 13 and 14 at the end of the array, then 0, 1, 2 and 3 after wrapping, which is 8. Here FRONT marks the first element and REAR the next free slot. The value 4 is just REAR itself, 5 and 6 match no count of the occupied slots, and treating REAR as the last element instead would give 9.

Please log in or register to report this question.

Loading…

Other Subjects

Tags: Queues Questions and Answers || Queues MCQ Questions and Answers || Queues GK Questions and Answers || Queues GK MCQ Questions || Queues Multiple Choice Questions and Answers || Queues GK || GK on Queues || Data Structures and Algorithms Questions and Answers || Data Structures and Algorithms MCQ Questions and Answers || Data Structures and Algorithms GK Questions and Answers || GK on Data Structures and Algorithms