Where to Use Dynamic Programming

In this lesson, we will learn about some problem characteristics in dynamic programming.

Dynamic programming, the magic wand

Do you remember the run time complexity of the Fibonacci algorithm from earlier lessons? We even saw how bad that algorithm performed as we tried to calculate a slightly higher (~50) Fibonacci number. We have modified that algorithm to remember the values it has already evaluated to avoid re-evaluations. Run this code with different values to see how much time the algorithm takes. For comparison, we have reproduced the simple recursion-based solution below as well as in the other tab.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy