When to prefer memoization over tabulation
A DP has a state space of possible states, but for a given input only about of them are actually reachable from the top-level query, and the dependency chains can be up to states deep. Both top-down memoization and bottom-up tabulation give the same big-O in the worst case. Which single statement correctly identifies the right approach for this input and why?
Show hints (2)+
- Only of states are reachable - which method skips the rest?
- But -deep recursion threatens the call stack - a fixable caveat, not a reason to switch.
Answer
Reveal answer →Final answer
Memoization - it computes only the reachable states, but the -deep recursion must be made iterative or given a larger stack
Create a free account to see the full worked solution and track your progress.
Interview format: Market Maker, Options Trading