Practice Flashcards
Flip to reveal answersWhat are the two halves of a recursive trace?
Track your progress — Sign up free to save your progress and get smart review reminders based on spaced repetition.
All 5 Flashcards — Tracing recursion
Sign up free to track progress and get spaced-repetition review schedules.
Question
What are the two halves of a recursive trace?
Answer
**Down** — each call is made and waits, with no arithmetic. **Up** — each returns a value, and the arithmetic happens.
Question
When does the arithmetic in n + recurse(n-1) happen?
Answer
On the way **up**, once the base case has returned a value to add to. Nothing is computed descending.
Question
How should a recursive trace be laid out?
Answer
Indent each call **one level further** than its caller; leave the return blank going down and fill it in coming back up.
Question
Which three questions build a recursive function?
Answer
**Base case**: which small input has a known answer? **Smaller step**: how does each call shrink the problem? **Combine**: what is done with the returned value on the way up?
Question
What happens if the base case is never reached?
Answer
The calls never stop: each adds a frame to the **call stack** until it overflows and the program crashes (**stack overflow**).
Read the notes
Full study notes for Tracing recursion
Topic 6.4 hub
Programming algorithms
More from Topic 6.4
All flashcards in this topic
Computer Science exam skills
Paper structures & tips
Track your progress with spaced repetition
Sign up free — Aimnova tells you exactly which cards to review and when, so you remember everything before your IB exam.
Start Free