Queues
A queue is a type of data structure where the first item you add to the data structure will be the first item that gets removed from the data structure. It is thus referred to as a FIFO (first in, first out) structure. Queues are generally implemented in two ways, the first of which, arrays, will be covered in this section. They can also be easily implemented by way of linked lists. Queues have two operations that can be performed on them: enqueueing (adding an item to the queue) and dequeueing (removing the least-recently added item from the queue).
-
Lecture
-
Shorts
-
Supplementary Resources
- Michael Olorunnisola on How Queues Work
- Omar El Gabry on Stacks and Queues
- Joe Birch on Data Structures: Stacks & Queues
-
Thought Questions
- What situations would a queue be useful for?
- Compare and contrast lists and queues. When would you prefer to use one and not the other?
- Find two examples of queue structures in real life. How does understanding how computers use them change the way you think about them?
-
Problem