A queue is a sequence of people or objects waiting to be attended to. Some examples include a queue of people waiting at a counter, a queue of swimmers that are ready to dive in to a pool, and a queue of songs in a playlist:
![](https://static.packt-cdn.com/products/9781789611151/graphics/assets/6e7fa6ab-615b-44e4-92bf-e084c5e9204e.png)
Just like in a stack, there are two types of operations—one for inserting items into a queue, and one for removing items from a queue. When a person joins a queue, he or she must stand behind the last person. The operation of adding an item to a queue is called enqueue. The first person to be attended to in a queue is the person standing in the front. The operation to remove an item from a queue is called dequeue. Queue operations can be seen in the following diagram:
![](https://static.packt-cdn.com/products/9781789611151/graphics/assets/7681900b-ad36-463c-a701-fa4a225ed277.png)
Since the first object inserted is the first one to be removed, this data structure is called first in first out (FIFO). In Python, we can use...