Dynamic Programming21 sections · 916 units
Open in Course

Section Recap

What we learned

You have learned recursion. You understand base cases, recursive cases, and the call stack. You can trace recursive calls and write recursive code.

You have seen single-parameter recursion (factorial, sum of digits) and two-parameter recursion (GCD). You have seen linear recursion (nn1n \to n-1) and logarithmic recursion (nn/2n \to n/2). Good job. Now you are ready for the next level: making recursion fast. Right now, factorial(100)\text{factorial}(100) works fine.

But some recursive solutions repeat the same work millions of times. The fix is called memoization. I will show you exactly how it works in the next section.