19 Dynamic Programming
19 Dynamic Programming
Algorithms
Dynamic programming
1
Dynamic programming
Well known algorithm design techniques:.
– Divide-and-conquer algorithms
2
Dynamic programming
Dynamic Programming is a general algorithm design
technique for solving problems defined by or formulated as
recurrences with overlapping sub instances.
Main idea:
- set up a recurrence relating a solution to a larger
instance to solutions of some smaller instances
- solve smaller instances once
- record solutions in a table
- extract solution to the initial instance from that table
3
Dynamic programming
Dynamic programming is a way of improving on inefficient
divide and-conquer algorithms.
4
Elements of Dynamic Programming
DP is used to solve problems with the following characteristics:
• Simple subproblems
– We should be able to break the original problem to smaller
subproblems that have the same structure
• Overlapping sub-problems
– there exist some places where we solve the same
subproblem more than once.
5
Steps to Designing a
Dynamic Programming Algorithm
6
Principle of Optimality
7
` Dynamic Programming vs.Divide & Conquer
8
` Dynamic Programming vs Greedy Method
9
Examples
•0/1 Knapsack Method
•Traveling sales person Problem
•Optimal Binary search tree
•Matrix chain multiplication
•Longest Common Sequence
10
Thank You
11