A queue is an ADT – Abstract Data Type or a linear data structure. It is a FIFO data structure because element inserted first will be removed first. FIFO stands for First-in-first-out. Queue use one end to insert data which is called REAR or tail and other end to remove the data which is called FRONT or head.

Queue operations

enqueue(): Insert an item to the queue.

dequeue(): Remove an item from the queue.

peek(): Get the top data element of the queue, without removing it.

isFull(): Check if queue is full.

isEmpty(): Check if queue is empty.

Queue states

Overflow state: A queue is in overflow state if it does not contain enough space to accept an entity to be inserted.

Underflow state: A queue is in underflow state if we want to operate stack with dequeue operation and the queue is empty.

Deque Queue

Double-ended queue is an abstract data type. A deque represents a linear collection of elements that support insertion, retrieval and removal of elements at both ends. Dequeue, often abbreviated to deque.