Skip to content
Computer Science · 12th Grade

Active learning ideas

Queues: FIFO Data Structure

Active learning works especially well for queues because fairness through FIFO ordering is intuitive in daily life but tricky to implement correctly in code. Students need to physically manipulate enqueue and dequeue actions to internalize how the abstraction matches real systems like printers or CPUs.

Common Core State StandardsCSTA: 3B-AP-12CSTA: 3B-AP-14
25–60 minPairs → Whole Class4 activities

Activity 01

Simulation Game25 min · Whole Class

Simulation Game: The Printer Queue

Students act as print jobs arriving at different times. The 'printer' (one designated student) processes jobs strictly in arrival order. After one round, introduce a priority variant where urgent jobs jump ahead. The class compares the two systems, discussing fairness, throughput, and starvation, making the design trade-offs tangible before they appear in code.

Compare the operational principles of stacks and queues and their respective use cases.

Facilitation TipDuring the Printer Queue simulation, hand out sticky notes so students can physically pass tasks to the 'printer' and witness gaps in the array grow visibly.

What to look forPresent students with a sequence of enqueue and dequeue operations on a queue. Ask them to trace the state of the queue after each operation and identify the element that will be dequeued next. Example: Given enqueue(A), enqueue(B), dequeue(), enqueue(C), dequeue(), what is the next element to be dequeued?

ApplyAnalyzeEvaluateCreateSocial AwarenessDecision-Making
Generate Complete Lesson

Activity 02

Collaborative Lab: Array-Based vs. Linked-List Queue

Pairs implement both an array-based and a linked-list-based queue with enqueue, dequeue, peek, and isEmpty methods. They benchmark both with a sequence of 1,000 operations and compare memory usage by counting the maximum number of variables in use at once. Pairs then write a brief design recommendation for each of two scenarios: a memory-constrained embedded system and a high-throughput server.

Design a system where a queue would be the most appropriate data structure for managing tasks.

Facilitation TipWhile implementing array vs. linked-list queues, ask students to annotate their code with index states at each step to reveal wasted space or null pointers.

What to look forPose the following scenario: 'Imagine you are designing a system for a busy coffee shop. Customers place orders, and the barista makes them in the order they arrive. Which data structure, a stack or a queue, would be most appropriate for managing these orders, and why? Describe the enqueue and dequeue operations in this context.'

ApplyAnalyzeEvaluateCreateRelationship SkillsDecision-MakingSelf-Management
Generate Complete Lesson

Activity 03

Think-Pair-Share30 min · Pairs

Think-Pair-Share: BFS and Queues

Show students a small graph and ask them individually to trace why a queue (not a stack) ensures that breadth-first search explores nodes level by level. Pairs compare their reasoning and then trace through the BFS algorithm step by step on a shared diagram, annotating the queue state after each enqueue and dequeue operation. This pairs data structure understanding with algorithm application.

Evaluate the performance characteristics of array-based versus linked-list-based queue implementations.

Facilitation TipFor the BFS think-pair-share, provide a small graph and colored markers so pairs can literally trace the queue order on paper before coding.

What to look forAsk students to write down one specific advantage of using a linked-list-based queue over an array-based queue, and one specific advantage of an array-based queue over a linked-list-based queue. They should also briefly explain why they chose these advantages.

UnderstandApplyAnalyzeSelf-AwarenessRelationship Skills
Generate Complete Lesson

Activity 04

Gallery Walk35 min · Pairs

Gallery Walk: Real-World Queue Systems

Post 5 real-world queue scenarios: airport check-in, hospital triage, CPU scheduling, message broker, HTTP request handling. For each, student pairs answer three questions: what is the queue storing, what determines order, and what happens if the queue is full or empty. Responses are compared during debrief, emphasizing how each system handles overflow or high-demand situations.

Compare the operational principles of stacks and queues and their respective use cases.

Facilitation TipIn the Gallery Walk, assign each pair one real-world scenario card to explain how their queue choices affect fairness or efficiency.

What to look forPresent students with a sequence of enqueue and dequeue operations on a queue. Ask them to trace the state of the queue after each operation and identify the element that will be dequeued next. Example: Given enqueue(A), enqueue(B), dequeue(), enqueue(C), dequeue(), what is the next element to be dequeued?

UnderstandApplyAnalyzeCreateRelationship SkillsSocial Awareness
Generate Complete Lesson

A few notes on teaching this unit

Start with the printer simulation to ground FIFO in a concrete, low-stakes task. Move quickly to the array vs. linked-list lab so students confront memory issues firsthand. Use the think-pair-share to bridge the abstract queue concept to BFS before they write any code. Avoid rushing through the linked-list implementation; many students need to draw pointers repeatedly to trust the links.

Successful learning looks like students confidently choosing the correct queue implementation for a given scenario, tracing operations without index errors, and explaining why a FIFO sequence matters in systems such as BFS or process scheduling.


Watch Out for These Misconceptions

  • During Simulation: The Printer Queue, watch for students assuming a stack would work just as well as a queue for print jobs.

    After the simulation, replay the same job sequence with a stack and ask students to compare the order of printed pages to the original FIFO output. Have them write a one-sentence rule explaining when a stack is appropriate for print jobs.

  • During Collaborative Lab: Array-Based vs. Linked-List Queue, watch for students believing the array-based queue never wastes memory.

    Ask students to trace an array-based queue through 10 enqueue and 6 dequeue operations. Have them circle the unused cells and calculate the wasted space percentage. Then ask them to propose one fix and implement it.

  • During Think-Pair-Share: BFS and Queues, watch for students equating any graph traversal with FIFO ordering.

    Present a small priority queue example alongside the BFS graph. Ask pairs to explain in one sentence why FIFO alone cannot handle priorities, then show how their BFS code would need to change.


Methods used in this brief