Skip to content
Computer Science · Grade 11

Active learning ideas

Implementing Stacks and Queues

Active learning works well here because students often confuse LIFO and FIFO rules, and hands-on practice with real code helps them internalize the differences. Small group simulations and pair work also let students verbalize their reasoning, which deepens their understanding of how stacks and queues behave in actual programs.

Ontario Curriculum ExpectationsCS.HS.A.3CS.HS.A.4
20–45 minPairs → Whole Class4 activities

Activity 01

Experiential Learning30 min · Pairs

Pair Programming: Stack Reversal

Pairs implement a stack using an array with push and pop methods. They input a string, push characters, then pop to reverse it, handling edge cases like empty strings. Pairs test multiple inputs and swap code for peer review.

Design an algorithm that uses a stack to reverse a string.

Facilitation TipDuring Pair Programming: Stack Reversal, encourage students to swap roles every two operations to keep both partners engaged in the logic.

What to look forPresent students with a sequence of operations for both a stack and a queue (e.g., push A, push B, pop, enqueue C, dequeue). Ask them to trace the state of each data structure after each operation and record the final output.

ApplyAnalyzeEvaluateSelf-AwarenessSelf-ManagementSocial Awareness
Generate Complete Lesson

Activity 02

Experiential Learning45 min · Small Groups

Small Groups: Queue Simulation

Groups build a linked-list queue for a bank line simulator, coding enqueue and dequeue. They add 20 customers, process service times, and output wait statistics. Groups present results and discuss FIFO behavior.

Compare the performance characteristics of array-based versus linked-list-based stacks and queues.

Facilitation TipIn Small Groups: Queue Simulation, provide real-world scenarios like ticket sales or printer queues to make the FIFO concept tangible.

What to look forAsk students to write a short paragraph explaining one scenario where a stack would be more appropriate than a queue, and one scenario where a queue would be more appropriate than a stack. They should justify their choices based on the LIFO and FIFO principles.

ApplyAnalyzeEvaluateSelf-AwarenessSelf-ManagementSocial Awareness
Generate Complete Lesson

Activity 03

Experiential Learning25 min · Whole Class

Whole Class: Performance Benchmark

Display array-based and linked-list stack code. Class runs timed tests on 1,000 operations, records results on shared board. Discuss why one outperforms in specific scenarios.

Construct a program that simulates a waiting line using a queue.

Facilitation TipFor Whole Class: Performance Benchmark, run the same test twice, once with arrays and once with linked lists, to highlight resizing costs.

What to look forFacilitate a class discussion comparing array-based versus linked-list-based implementations. Ask: 'When might an array-based stack be preferred, even if it means potential wasted space? When would a linked list's flexibility be essential for a queue?'

ApplyAnalyzeEvaluateSelf-AwarenessSelf-ManagementSocial Awareness
Generate Complete Lesson

Activity 04

Experiential Learning20 min · Individual

Individual: Mixed Implementation

Students choose array or linked list to code both stack and queue, solving a provided problem like task scheduling. They self-test with unit cases and note pros/cons.

Design an algorithm that uses a stack to reverse a string.

Facilitation TipDuring Individual: Mixed Implementation, give a starter code snippet that intentionally uses the wrong structure for the task, so students debug the mismatch.

What to look forPresent students with a sequence of operations for both a stack and a queue (e.g., push A, push B, pop, enqueue C, dequeue). Ask them to trace the state of each data structure after each operation and record the final output.

ApplyAnalyzeEvaluateSelf-AwarenessSelf-ManagementSocial Awareness
Generate Complete Lesson

A few notes on teaching this unit

Start with concrete, relatable examples like undo features for stacks or printer queues for queues to ground abstract rules. Avoid teaching these structures in isolation—instead, pair each new operation with a real problem students care about. Research shows that tracing paper or whiteboard sketches helps students visualize pointers and shifts in state, so include these visual tools often. Finally, emphasize that the choice between array and linked list depends on the context, not a universal rule.

By the end of these activities, students should confidently trace stack and queue operations, choose the right implementation for a task, and compare performance trade-offs using Big O notation. They will also articulate why one structure fits a problem better than the other, backing claims with data from benchmarks.


Watch Out for These Misconceptions

  • During Pair Programming: Stack Reversal, watch for students who treat stack and queue operations interchangeably.

    Have them pause after each operation to sketch the stack’s state with arrows and labels, then repeat the process for a queue with the same inputs to highlight the divergence.

  • During Whole Class: Performance Benchmark, watch for students who assume arrays are always faster due to indexing speed.

    Ask groups to increase the dataset size until the linked list’s insertion time becomes noticeably faster, then discuss memory fragmentation in arrays as the cause.

  • During Small Groups: Queue Simulation, watch for students who ignore the FIFO rule when modeling real-world systems.

    Require them to map each enqueue and dequeue operation to a specific person or item in their scenario, forcing them to follow the order strictly.


Methods used in this brief