What is memoization in the context of dynamic programming?
Memoization is a technique where we 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 top-down dynamic programming differ from bottom-up dynamic programming?
Top-down DP solves the problem by breaking it into subproblems recursively and storing results (memoization), while bottom-up DP solves smaller subproblems first and builds up to the solution iteratively.
Click to reveal answer
beginner
In memoization, what data structure is commonly used to store intermediate results?
An array or a hash map (dictionary) is commonly used to store intermediate results indexed by the subproblem parameters.
Click to reveal answer
intermediate
Why is memoization useful in recursive algorithms?
Memoization prevents repeated work by saving results of subproblems, which reduces the time complexity from exponential to polynomial in many cases.
Click to reveal answer
beginner
What is the base case role in a top-down DP memoized function?
The base case provides the simplest answer without recursion, stopping the recursion and allowing the function to build solutions for bigger problems.
Click to reveal answer
What does memoization store to optimize recursive calls?
AInput parameters only
BResults of subproblems
CAll function calls
DRandom values
✗ Incorrect
Memoization stores results of subproblems to avoid recalculating them.
Which of the following best describes top-down DP?
ARecursive with memoization
BIterative without recursion
CGreedy approach
DBrute force search
✗ Incorrect
Top-down DP uses recursion combined with memoization to solve problems.
What happens if you do not use memoization in a recursive Fibonacci function?
AIt never finishes
BIt runs faster
CIt uses less memory
DIt runs exponentially slower
✗ Incorrect
Without memoization, recursive Fibonacci recalculates many subproblems, causing exponential time.
Which data structure is NOT typically used for memoization?
AArray
BHash map
CStack
DDictionary
✗ Incorrect
Stacks are used for function calls, not for storing memoized results.
What is the main benefit of using top-down DP with memoization?