Queues

Week 5, Wednesday

February 4, 2026

Recap: Stack ADT

Programmatic realization of a pile of stuff.


Stack functions:

  • Insert: push(item)
  • Remove: pop()item

LIFO: Last In, First Out

Abstract Data Type (ADT) Queue

Programmatic realization of standing in line.


Queue functions:

  • Insert: enqueue(item)
  • Remove: dequeue()item

FIFO: First In, First Out


Python: from collections import deque

  • Insert: append(item)
  • Remove: popleft()item

A line of penguins on an ice floe, jumping into the ocean one by one.

Your Turn

Each of you has been given your own set of instructions that when executed, will reveal something great.

Complete the activity in PL to solve the puzzle!