Skip to content
Computer Science · Grade 12

Active learning ideas

Recursive Problem Solving: Basics

Active learning works because recursion demands mental visualization of processes that unfold step by step, which static examples cannot capture. When students physically trace recursion trees or debug missing base cases in real code, they build durable mental models of how recursion unfolds, moving beyond abstract definitions into concrete understanding.

Ontario Curriculum ExpectationsCS.P.15CS.AA.5
20–35 minPairs → Whole Class4 activities

Activity 01

Problem-Based Learning30 min · Pairs

Pair Coding: Factorial Recursion

Pairs write a recursive factorial function in Python, including a base case for n=0 or 1. They test with inputs from 1 to 10, printing each recursive call. Discuss outputs and modify to return values only.

How do you determine if a problem is better solved through recursion or iteration?

Facilitation TipDuring Pair Coding: Factorial Recursion, circulate and ask pairs to explain their recursive step aloud before coding it to surface misconceptions early.

What to look forPresent students with a pseudocode snippet of 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 removed.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 02

Problem-Based Learning25 min · Small Groups

Small Groups: Recursion Tree Drawing

Groups draw recursion trees for Fibonacci(5), labeling sub-calls and base cases. Compare trees for factorial(4). Share drawings class-wide to identify patterns in call depth.

Explain the role of the base case in preventing infinite execution in recursive functions.

Facilitation TipFor Recursion Tree Drawing, provide graph paper or digital tools and limit each group to a single function to prevent overcomplicating their first attempt.

What to look forProvide students with the problem of calculating the sum of numbers from 1 to n. Ask them to write a recursive function for this problem and briefly explain why their chosen base case is correct.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 03

Problem-Based Learning35 min · Whole Class

Whole Class: Tower of Hanoi Demo

Project a recursive Tower of Hanoi solution for 3 disks. Class predicts moves step-by-step, then runs code. Vote on base case modifications and observe effects.

Construct a recursive solution for a simple problem like factorial calculation.

Facilitation TipIn the Tower of Hanoi Demo, pause after each move to ask students to predict the next recursive call before it happens, reinforcing pattern recognition.

What to look forFacilitate a class discussion comparing a recursive solution for finding the nth Fibonacci number with an iterative one. Ask students to articulate the trade-offs in terms of code readability and potential performance differences.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 04

Problem-Based Learning20 min · Individual

Individual: Iteration vs Recursion Trace

Students trace recursive and iterative Fibonacci(6) on paper, counting operations and stack frames. Code both versions and time execution for n=30.

How do you determine if a problem is better solved through recursion or iteration?

Facilitation TipFor the Iteration vs Recursion Trace, require students to label each stack frame with variable values to make overhead concrete and memorable.

What to look forPresent students with a pseudocode snippet of 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 removed.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

A few notes on teaching this unit

Start with concrete examples students already know, like factorial, before moving to abstract problems. Avoid diving too quickly into mathematical proofs of recursion’s correctness, as students benefit more from tracing and debugging first. Research suggests pairing recursion with visual tools like recursion trees improves comprehension more than lectures alone. Emphasize that recursion is a design tool, not just a performance choice, and highlight readability wins in problems that naturally fit divide and conquer.

Successful learning looks like students confidently identifying base cases and recursive steps in new problems, tracing execution paths without confusion, and articulating trade-offs between recursion and iteration. They should also recognize when recursion adds clarity despite its overhead and avoid common pitfalls like infinite recursion or stack overflows.


Watch Out for These Misconceptions

  • During Pair Coding: Factorial Recursion, watch for students assuming recursion is faster because it looks elegant.

    Guide pairs to insert print statements tracing each call and return, then count operations versus an iterative loop to reveal recursion’s overhead in time and memory.

  • During Small Groups: Recursion Tree Drawing, watch for students omitting base cases or recursive steps entirely.

    Ask groups to label each node in their tree with the base case or recursive step it represents, forcing them to confront missing elements directly.

  • During Individual: Iteration vs Recursion Trace, watch for students treating base cases as optional even in simple problems.

    Have students intentionally remove the base case in their trace and run the code, then analyze the resulting stack overflow or infinite loop together.


Methods used in this brief