Data Structures & AlgorithmsHardCodeforces Div2 B · DP warm-up

Problem: Which best explains the time complexity difference between recursive (top-down with memoization) and iterative (bottom-up tabulation) DP solutions to the same problem with n states?

  1. A. Recursive memoization is always asymptotically slower
  2. B. Both are typically O(n) (or whatever the per-state work is) asymptotically, but recursion adds call-stack overhead and risk of stack overflow for large n
  3. C. Recursion is always faster because it skips unnecessary states
  4. D. Iterative tabulation cannot handle problems with more than one dimension

Correct answer: B. Both are typically O(n) (or whatever the per-state work is) asymptotically, but recursion adds call-stack overhead and risk of stack overflow for large n

Both approaches compute each distinct state exactly once, giving the same asymptotic complexity; the practical difference is that recursion incurs function-call overhead and can hit a stack-depth limit, while iteration avoids both.

More Coding Interview Problems questions

Exams that ask this topic