Recall & Review
beginner
What is memoization in the context of recursion?
Memoization is a technique to store the results of expensive function calls and reuse them when the same inputs occur again, avoiding repeated calculations.
Click to reveal answer
beginner
How does memoization improve the performance of recursive functions?
It saves the results of recursive calls in a cache (like an array or dictionary) so that each unique call is computed only once, reducing time complexity from exponential to linear in many cases.
Click to reveal answer
intermediate
In C, what data structure is commonly used to implement memoization for recursion?
An array or a hash table (if keys are not simple integers) is commonly used to store computed results for memoization in C.
Click to reveal answer
intermediate
What is the difference between memoization and dynamic programming?
Memoization is a top-down approach that caches results of recursive calls, while dynamic programming is often a bottom-up approach that builds solutions iteratively. Both avoid repeated work but differ in implementation style.
Click to reveal answer
beginner
Why is memoization especially useful in problems like Fibonacci sequence calculation?
Because naive recursion recalculates the same Fibonacci numbers many times, memoization stores these results once computed, drastically reducing the number of calls and improving efficiency.
Click to reveal answer
What does memoization store to optimize recursion?
✗ Incorrect
Memoization stores previously computed results to avoid recalculating them.
Which data structure is commonly used for memoization in C when inputs are integers?
✗ Incorrect
Arrays are commonly used to store memoized results indexed by integer inputs.
Memoization changes the time complexity of naive Fibonacci recursion from exponential to what?
✗ Incorrect
Memoization reduces Fibonacci recursion time complexity to linear by caching results.
Memoization is an example of which programming technique?
✗ Incorrect
Memoization is a top-down approach that caches recursive calls.
What happens if memoization is not used in recursive functions with overlapping subproblems?
✗ Incorrect
Without memoization, recursive functions with overlapping subproblems recompute results repeatedly.
Explain how memoization optimizes a recursive function using the Fibonacci sequence as an example.
Think about how many times the same Fibonacci number is calculated without memoization.
You got /4 concepts.
Describe the steps to implement memoization in a recursive C function.
Focus on how to avoid repeated work by checking and storing results.
You got /5 concepts.