What is “dynamic programming”? How does it work?

1.82K views

Having a hard time wrapping my head on why it is so special.

In: Technology

2 Answers

Anonymous 0 Comments

Dynamic programming is a strategy that incorporates memoization. The whole point is to store results and then reference them to make a more efficient algorithm. From a programming perspective these results are stored in a 2d array. One example is the 0-1 knapsack problem (all or nothing weights). Basically given a max knapsack weight and many items with weights, you can calculate how many items can fit within that weight and build upon it. If you want a more detailed analysis on how the knapsack problem is solved through dynamic programming, [this](https://youtu.be/8LusJS5-AGo) is a pretty good run down of how to go about it. One thing I want to emphasize is that dynamic programming is not a single algorithm, its just a technique used to speed up algorithms.

ELI5 Version:
Run algorithms that store the results so you can reference them later without rerunning the calculation.

You are viewing 1 out of 2 answers, click here to view all answers.