Which of the following conditions correctly check the underflow condition in a…
2018
Which of the following conditions correctly check the underflow condition in a queue?
- A.
front = -1
- B.
rear = 1
- C.
rear = size
- D.
front = size
Attempted by 182 students.
Show answer & explanation
Correct answer: A
The correct option is A. In a standard array-based queue implementation, an underflow condition occurs when trying to dequeue from an empty queue. Initially, when the queue has no elements, the front (and rear) pointers are traditionally initialized to -1. Therefore, front == -1 signifies underflow.