Recall & Review
beginner Click to reveal answer
What is recursion in simple terms?
Recursion is when a function calls itself to solve smaller parts of a problem until it reaches a simple case it can solve directly.
beginner Click to reveal answer
Why do we need recursion when we already have loops?
Recursion helps solve problems that have a natural 'divide and conquer' structure or nested patterns that loops find hard to express clearly.
intermediate Click to reveal answer
Give an example of a problem where loops are not clean but recursion is natural.
Calculating factorial or traversing a tree structure is easier and cleaner with recursion than with loops.
beginner Click to reveal answer
What is a base case in recursion and why is it important?
A base case is the simplest version of the problem that can be solved directly. It stops the recursion from continuing forever.
intermediate Click to reveal answer
How does recursion help express problems with nested or hierarchical data?
Recursion naturally breaks down nested or hierarchical data by calling itself on smaller parts, matching the structure of the data.
Which of these problems is best solved using recursion?
✗ Incorrect
Factorial calculation naturally fits recursion because it breaks down into smaller factorial problems.
What stops a recursive function from running forever?
✗ Incorrect
The base case defines when recursion should stop by solving the simplest problem directly.
Which of these is NOT a reason to use recursion?
✗ Incorrect
Recursion is not used just to avoid loops; loops are useful and sometimes better for simple repetitive tasks.
Loops struggle to express problems that are:
✗ Incorrect
Nested or hierarchical problems are cleaner to express with recursion than with loops.
What is a key difference between loops and recursion?
✗ Incorrect
Recursion solves problems by breaking them down, while loops repeat the same steps until a condition is met.
Explain why recursion is useful for problems that loops cannot express cleanly.
Think about how recursion matches the problem's structure.
You got /4 concepts.
Describe the role of the base case in recursion and what happens if it is missing.
Base case is like a stopping point.
You got /4 concepts.
