A queue is a first in, first out (FIFO) structure. This means that the first item to join the queue is the first to leave the queue. A queue can be implemented using an array (called a list in Python), or using OOP techniques.
A list implementation for a linear queue will use an append method to add to the queue and a delete method to remove from the queue.
Another type of queue is a circular queue. With this type of queue, if the end of the available spaces are reached, then the next item to be added uses any available spaces at the start of the queue. This is a more efficient use of space.
Implementing the queue class using OOP.
This video shows how a queue class can be implemented.
- First implement a queue as a list which you add and delete items from.
- Next, follow the video instructions above and implement the Queue class.
- A more efficient form of queue is a circular queue. In this type of queue, the beginning items of the queue can be reused. Implement a circular queue using either method.