Queues
A queue is a data structure that allows you to add a new element only at the end of the queue (referred to as an enqueue operation) and to get an element only from the beginning of the queue (a dequeue operation). For this reason, a queue is consistent with the FIFO principle, which stands for First-In First-Out.
Imagine a queue
If you want to better imagine a queue, let’s take a break from learning data structures and algorithms, wear your favorite jacket, and go to a shop in the vicinity. You buy your favorite ice cream, and you see five people waiting for checkout. Oh no... You are the last one, so you need to wait until the first, second, third, fourth, and fifth person pay. These lines in shops can be frustrating! In general, new people stand at the end of the line, and the next person is taken to the checkout from the beginning of the line. No one is allowed to choose a person from the middle and serve them in a different order. The queue data structure operates...