Dynamic Programming21 sections · 916 units
Open in Course

Intro

The power of optimization

Okay, so now you know recursion. Now, how can you make it faster. Here's a challenge: write a function to compute the 50th Fibonacci number using recursion. Run it. I'll wait... Did it finish? Probably not.

Your computer is doing billions of redundant calculations right now. By the end, you'll add 33 lines of code that make it finish in milliseconds. The technique is called memoization (I'll explain exactly what this means in Unit 1111).