The queue data structure
Queues are all around us in everyday life. Think of the line to buy a movie ticket, the cafeteria queue at lunchtime, or the checkout line at the grocery store. In each of these scenarios, the underlying principle is the same: the first person to join the queue is the first one to be served.

An extremely popular example in computer science is the printing line. Let's say we need to print five documents. We open each document and click on the Print button. Each document will be sent to the print line. The first document that we asked to be printed is going to be printed first and so on, until all the documents are printed.
In the realm of data structures, a queue is a linear collection of elements that adheres to the First In, First Out (FIFO) principle, often referred to as First Come, First Served. New elements are always added at the rear (end) of the queue, while...