Lesson Plan

Lesson Plan
Grade: Date: 17/01/2026
Subject: Computer Science
Lesson Topic: Show awareness of what a compiler has to do to translate recursive programming code
Learning Objective/s:
  • Describe the compiler phases involved in translating a recursive function.
  • Explain how activation records are created and managed on the call stack.
  • Identify when tail‑call optimisation can be applied and its effect on memory usage.
  • Analyse a simple recursive example (e.g., factorial) and trace the generated code steps.
Materials Needed:
  • Projector or interactive whiteboard
  • Slides showing compiler phases and stack diagram
  • Sample code worksheets (factorial example)
  • IDE/compiler demo (e.g., gcc) on classroom computers
  • Handout of activation‑record layout table
Introduction:
Begin with a quick question: What happens inside a program when a function calls itself? Review prior learning on recursion and call‑stack basics. Explain that today’s success criteria are to understand how a compiler translates such calls and to recognise optimisation opportunities.
Lesson Structure:
  1. Do‑now (5') – Students answer a short prompt about recursion behaviour.
  2. Mini‑lecture (10') – Overview of compiler phases for recursive code, using slides.
  3. Walkthrough (15') – Step‑by‑step translation of the factorial function, highlighting activation‑record creation.
  4. Guided practice (10') – In pairs, students annotate a worksheet showing stack changes for several recursive calls.
  5. Optimisation demo (10') – Demonstrate tail‑call optimisation with an example and discuss applicability.
  6. Check for understanding (5') – Quick quiz (Kahoot) on key concepts.
Conclusion:
Summarise how the compiler builds the call stack and where optimisation can reduce its depth. Have students write an exit‑ticket note describing a situation where tail‑call optimisation would be beneficial. Assign homework to research how another programming language handles recursion and optimisation.