Underflow Check
Before dequeuing, we must check if the queue is empty (`front == -1` or `front > rear`). Dequeuing from an empty queue causes an Underflow error.
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
Dequeue is the process of removing an element from a Queue. In a FIFO structure, removals always happen at the 'Front'.
Before dequeuing, we must check if the queue is empty (`front == -1` or `front > rear`). Dequeuing from an empty queue causes an Underflow error.
We read the value at the `front` index, and then increment `front` by 1. The element isn't necessarily deleted from memory immediately, but it is ignored by the queue logic.
If `front` overtakes `rear` after a dequeue, it means the queue has become completely empty. We reset both pointers to `-1`.