A queue can be defined as an ordered list which enables insert operations to be performed at one end called REAR and delete operations to be performed at another end called FRONT.
A queue is a linear data structure that follows the First In, First Out (FIFO) principle, meaning that the element inserted first will be the one to be removed first. It supports two primary operations:
- Enqueue: This operation adds an element to the rear or end of the queue.
- Dequeue: This operation removes an element from the front or beginning of the queue.
Additionally, some other common operations associated with queues include:
- Peek: This operation allows you to view the element at the front of the queue without removing it.
- IsEmpty: This operation checks if the queue is empty.
- IsFull (in some implementations): This operation checks if the queue has reached its maximum capacity.
Queues can be implemented using arrays, linked lists, or other data structures, with each implementation having its own advantages and disadvantages in terms of time and space complexity for various operations.