A queue is an ordered list that allows insert operations to be done at one end (REAR) and delete operations to be performed at the other end (FRONT). The First In First Out list is referred to as a queue.
It is a linear structure that performs operations in a specific order. The order is as follows: First In, First Out (FIFO). Any queue of consumers for a resource where the consumer who arrive first is serve first is an example of a this. The only difference between stacks and queues is how they remove. In a stack, we remove the most recently added item; in a queues, we remove the item that added to the least recently.
Fig : Queue
For example, create a queue, People in line for a train ticket.
Operation on Queue
- Add – The enqueue action is uses to add the element to the queue’s backend. It gives a void result.
- Delete – The dequeue operation is uses to remove items from the queue’s front end. It also returns the front-end element that remove. It gives you an integer value as a result. It’s also possible to make the dequeue operation void.
- Full (overflow) – When the queues is totally full, the overflow condition appears.
- Empty (underflow) – The underflow condition is thrown when the Queues is empty, that is, when there are no elements in the Queue.
Interested in learning about similar topics? Here are a few hand-picked blogs for you!