Discussion
In an array-based implementation of a circular queue, overflow occurs when
Answer: D
Overflow occurs when (rear + 1) % size == front.
In the usual array implementation, one slot is kept empty so that a full queue can be told apart from an empty one. The queue is full when advancing rear by one position, wrapping round with the modulus, would land on front.
\[ (rear + 1) \bmod size = front \Rightarrow \text{full} \]
rear == front is the test for an empty queue in this scheme. rear == size - 1 is the overflow test for a linear queue; in a circular queue there may still be free slots at the start of the array. front == -1 is how some implementations mark an empty queue, not a full one.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development