B2.4 Programming algorithmsB2.4.5
Constructing and Tracing Recursive Algorithms (AHL)
Construct and trace recursive algorithms in a programming language
AHL≈ 60 minCommand term: ConstructPremium
In this lesson
- Constructing simple, non-branching recursive functions in Java and Python
- Tracing recursive calls with a trace table, including the values returned
- Following code that runs before and after a recursive call
- Comparing a recursive function with an iterative version
This lesson is part of Premium
Every topic has one free lesson. Premium unlocks every interactive lesson, the exam-style questions at the end of each one, and the rest of Praxis IB.
What's inside
- LearnWriting a recursive function
- CodeThe sum of 1 to n
- CodeRaising to a power
- CheckTrace the calls
- CodeRecursion on strings
- LabBefore and after the call
- CodeA mystery function
- CheckQuick check
- CodeTry it: counting a character
- LearnRecursion or a loop?
- CodeFactorial without recursion
- ExamWorked exam answer
- ReviewMistakes examiners see
- Exam practiceExam-style questions
Ends with 4 exam-style questions worth 13 marks, with a self-marking markscheme.