Recall & Review
beginner
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.
Click to reveal answer
beginner
What is iteration in simple terms?
Iteration means repeating a set of instructions using loops like for or while until a condition is met.
Click to reveal answer
intermediate
When is recursion better than iteration?
Recursion is better when the problem naturally breaks into similar smaller problems, like tree traversals or divide and conquer algorithms.
Click to reveal answer
intermediate
When is iteration better than recursion?
Iteration is better when you want to save memory and avoid the overhead of function calls, especially for simple loops or when recursion depth can be very large.
Click to reveal answer
intermediate
What is a risk of using recursion too deeply?
Using recursion too deeply can cause a stack overflow error because each function call uses memory on the call stack.
Click to reveal answer
Which of these problems is best solved using recursion?
✗ Incorrect
Factorial naturally breaks down into smaller factorials, making recursion a good fit.
What is a main disadvantage of recursion compared to iteration?
✗ Incorrect
Each recursive call adds a new frame to the call stack, using more memory.
Which method is usually more efficient in terms of memory?
✗ Incorrect
Iteration uses a fixed amount of memory for loop variables, while recursion uses extra memory for each call.
What is a base case in recursion?
✗ Incorrect
The base case stops the recursion to prevent infinite calls.
Which of these is a sign to prefer iteration over recursion?
✗ Incorrect
Simple repeated steps are easier and more efficient with iteration.
Explain in your own words when recursion is a better choice than iteration.
Think about problems like exploring folders or splitting arrays.
You got /3 concepts.
Describe the main risks or downsides of using recursion too much.
Consider what happens when a function calls itself many times.
You got /3 concepts.