Skip to content
Computer Science · Grade 11

Active learning ideas

Implementing Recursive Algorithms

Active learning works well here because recursive thinking is abstract, and students need to see the call stack in action to grasp how each recursive call builds on the last. Working in pairs or small groups turns the invisible process of recursion into a shared visual and tactile experience, reducing confusion about base cases and stack frames.

Ontario Curriculum ExpectationsCS.HS.A.2CS.HS.A.3
25–45 minPairs → Whole Class4 activities

Activity 01

Pair Programming: Factorial and Fibonacci Coders

Pairs write recursive functions for factorial and Fibonacci, test with inputs from 0 to 10, and trace calls on paper. They then rewrite one iteratively and compare outputs and code length. Discuss which approach suits each problem.

Design a recursive function to solve a given problem, identifying the base case and recursive step.

Facilitation TipBefore starting Pair Programming, ask each pair to sketch the call stack on paper for the first three steps of their chosen function to ensure they see how the frame grows and shrinks.

What to look forPresent students with a pseudocode snippet for a recursive function (e.g., factorial). Ask them to identify the base case and the recursive step, and explain what would happen if the base case were missing.

ApplyAnalyzeEvaluateCreateRelationship SkillsDecision-MakingSelf-Management
Generate Complete Lesson

Activity 02

Collaborative Problem-Solving45 min · Small Groups

Small Groups: Tree Traversal Simulator

Groups draw binary trees on paper and implement inorder, preorder, postorder traversals recursively. They simulate execution by marking visit order with colors and swap trees to test peers' code. Note differences in output sequences.

Compare the readability and conciseness of recursive versus iterative solutions for specific problems.

Facilitation TipFor the Tree Traversal Simulator, have groups use index cards labeled with node values and arrows to physically rearrange the tree and trace the path together.

What to look forPose the question: 'When might you choose a recursive solution over an iterative one, even if the iterative solution is more memory efficient? Discuss specific scenarios and the trade-offs involved, considering factors like code clarity and problem structure.'

ApplyAnalyzeEvaluateCreateRelationship SkillsDecision-MakingSelf-Management
Generate Complete Lesson

Activity 03

Collaborative Problem-Solving25 min · Whole Class

Whole Class: Stack Overflow Hunt

Project recursive code with deep calls; class predicts outcomes step-by-step on shared screen. Run in IDE to trigger overflow, then brainstorm limits like tail recursion. Vote on fixes via polls.

Evaluate the potential for stack overflow errors in deeply recursive functions.

Facilitation TipDuring the Stack Overflow Hunt, bring in a stack of paper cups to model the call stack, letting students watch the stack grow and topple when limits are reached.

What to look forGive students a simple problem (e.g., sum of numbers from 1 to n). Ask them to write a recursive function to solve it and then write one sentence explaining a potential drawback of their solution.

ApplyAnalyzeEvaluateCreateRelationship SkillsDecision-MakingSelf-Management
Generate Complete Lesson

Activity 04

Collaborative Problem-Solving30 min · Individual

Individual: Efficiency Duel

Students code recursive and iterative Fibonacci, time runs for n=35 using timers, and graph results. Submit reports comparing space use and readability with code snippets.

Design a recursive function to solve a given problem, identifying the base case and recursive step.

Facilitation TipIn the Efficiency Duel, provide a timer app so students can measure milliseconds and compare recursive versus iterative results directly on their devices.

What to look forPresent students with a pseudocode snippet for a recursive function (e.g., factorial). Ask them to identify the base case and the recursive step, and explain what would happen if the base case were missing.

ApplyAnalyzeEvaluateCreateRelationship SkillsDecision-MakingSelf-Management
Generate Complete Lesson

A few notes on teaching this unit

Experienced teachers approach recursion by first making the invisible visible: use whiteboard sketches, physical props, or digital animations to show how each call adds a frame. Avoid starting with the most complex example; begin with factorial because it has one clear base case and one recursive step. Emphasize tracing over writing early on, because students often confuse the structure of a recursive function with its implementation. Research shows that students benefit from comparing recursive and iterative solutions side by side to understand trade-offs in clarity and performance.

Successful learning looks like students confidently identifying base cases and recursive steps in multiple problems, tracing recursive calls on paper or whiteboards without prompting, and justifying why a recursive approach fits one problem but not another. You’ll see students debug missing base cases independently and propose optimizations like memoization after timing challenges.


Watch Out for These Misconceptions

  • During Pair Programming: Factorial and Fibonacci Coders, watch for students assuming recursive solutions are always faster.

    During Pair Programming, ask each pair to time both their recursive and iterative solutions using their devices’ timers, then compare results and discuss why naive recursion is slower for Fibonacci due to repeated calculations.

  • During Pair Programming: Factorial and Fibonacci Coders, watch for students treating base cases as optional.

    During Pair Programming, have each pair trace their function on paper with sample inputs, stopping at each call to confirm the base case is reached and the stack unwinds correctly.

  • During Whole Class: Stack Overflow Hunt, watch for students believing stack overflow only happens with extremely large inputs.

    During Whole Class, use the stack of paper cups to simulate a call stack and gradually increase the depth until the cups topple, showing how moderate depths can cause overflow if base cases are missing or inputs are large.


Methods used in this brief