Introduction to Queue
- A queue is a linear data structure in computer science that follows the First-In-First-Out (FIFO) principle in which the insertion of elements is done at the rear (tail) end and the removal of elements is done at the front (head) end.
- In a queue, the element that is inserted first is the first one to be removed, hence it implies the FIFO principle.
The queue operations can be summarized as follows:
- enqueue (or push): Add an element to the rear of the queue
- dequeue (or pop): Remove the element from the front of the queue
- front: Get the value of the element at the front of the queue
- empty: Check if the queue is empty
A queue can be implemented using an array, a linked list, or a dynamic array (such as a vector in C++ or ArrayList in Java). In programming, queues are used to implement algorithms like breadth-first search, round-robin scheduling, and more.
Contact Us