Skip to content

Latest commit

 

History

History
32 lines (21 loc) · 1.91 KB

Dynamic_Programming.md

File metadata and controls

32 lines (21 loc) · 1.91 KB

Dynamic Programming

Dynamic Programming is mainly an optimization over plain recursion. Wherever we see a recursive solution that has repeated calls for same inputs, we can optimize it using Dynamic Programming.

The idea of solving any problem using Dynamic Programming is to divide a problem into 'overlapping' subproblems and then reconstructing the solution using these subproblems.

Difference between Dynamic Programming and Greedy Algorithm:

Greedy Algorithm Dynamic Programming
Immediate best solution Optimal best solution
Sometimes gives optimal solution Always gives optimal solution
Subproblems are not depended Subproblems are interdepended
Faster runtime Slower runtime

Problems based on Dynamic Programming:

1. Matrix Chain Multiplication

2. Bellman Ford

3. 0/1 Knap Sack

4. Subset Sum

5. Weighted Interval Scheduling

6. Longest Increasing Subsequence

7. Sequence Allignment

8. Approximate String Matching

9. Segmented Least Square

10. Min Cost Path