Queues

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.

Queue

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.


Exercises

  1. First implement a queue as a list which you add and delete items from.
  2. Next, follow the video instructions above and implement the Queue class.
  3. 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.