Correct option is A
An underflow condition in a queue occurs when we try to delete an element from an empty queue.
In a standard implementation of a queue (especially in linear arrays), a common way to check whether the queue is empty is to test if front == -1. This value signifies that no elements are present in the queue yet or all elements have been removed.
Important Key Points:
- Underflow occurs when deletion is attempted on an empty queue.
- The condition front = -1 is typically used to represent an empty queue.
- Once the first element is inserted, front is usually set to 0. Resetting it to -1 indicates queue has become empty again.
Knowledge Booster:
- rear = 1: This indicates the rear index is at position 1, which is not a reliable indicator of underflow; the queue may still contain elements.
- rear = size: This condition relates to overflow, not underflow. It means the rear pointer has reached the end of the array.
- front = size: If front equals size, it typically means the pointer has gone out of bounds or all elements have been dequeued in a circular queue; still not a direct check for underflow in standard linear queue.