Queue
In computer science, a queue is a data structure that holds a list of tasks or data items waiting to be processed, following a First-In, First-Out (FIFO) principle, similar to a physical line. The two main operations are enqueue, which adds an item to the end (rear), and dequeue, which removes an item from the beginning (front). This structure is used to manage resources, schedule tasks, and handle data transfers in an orderly manner.
Key concepts
First-In, First-Out (FIFO): The first item added to the queue is the first one to be removed and processed.
Enqueue: The process of adding a new item to the end of the queue.
Dequeue: The process of removing an item from the front of the queue.
Front: The end of the queue where items are removed. The peek or front operation allows viewing the item at the front without removing it.
Rear: The end of the queue where new items are added.