Chapter 13: Dynamic
Programming
objectives
Dynamic Programming
Dynamic Programming approach
Component of Dynamic Programming
(DP)
Components of DP
Principle of Optimality
Detailed Procedure of DP
Forward and Backward Computing
Procedure
Properties of DP
Properties Contd..
Advantages and Disadvantages of DP
Comparison between DP and Divide &
Conquer
Comparison between DP and Greedy
approach
Fibonacci Problem
Fibonacci Tree
Complexity analysis of Traditional
approach
Fibonacci (DP) Approach – Table
approach
Scheduling Time
Informal modified algorithm
Formal algorithm
Formal algorithm
Complexity Analysis
Binomial Coefficient
Recursive Tree
Formal algorithm
Informal algorithm
Table
Formal algorithm
Formal algorithm
Complexity analysis
Example
Multistage Graph Problem
Informal algorithm
Activity Selection Problem
Steps
Steps
Steps
Steps
Steps
Formal algorithm
Formal algorithm for path construction
Backward Computation
Example
Example
Example
Example
Complexity analysis
Transitive closure
Brute force approach
Informal Warshall algorithm
Formal algorithm
Complexity analysis
Example
Example
Example
Example
Final conclusion
Alternative method
Example
Formal algorithm
Formal algorithm
Complexity analysis
Example
Example
Optimal Storage Problem
Informal Floyd-Warshall algorithm
Example
Example
Example
Example
Formal algorithm
Formal algorithm
Formal algorithm for path construction
Complexity Analysis
Bellman-Ford algorithm
Initialization
Relaxation rules
Informal algorithm
Example
Example
Example
Formal algorithm
Complexity analysis
Traveling Salesperson Problem
Traveling Salesperson Problem
Informal algorithm
Informal algorithm
Example
Example
Solution
Final Solution
Final Solution
Complexity analysis
Chain matrix multiplication
Example
Dynamic programming formulation
Informal algorithm
Informal algorithm for optimal order
Formal algorithm
Complexity analysis
Example
Example
Example
Final solution
Knapsack Problem
Mathematical formulation
Informal algorithm
Formal algorithm
Complexity analysis
Example
Example
Example
Example
Optimal BST – What is BST?
BST
OBST
Let's assume that frequencies associated with the keys 10, 20, 30 are 3, 2, 5.
The above trees have different frequencies. The tree with the lowest frequency would be considered the
optimal binary search tree. The tree with the frequency 17 is the lowest, so it would be considered as the
optimal binary search tree.
1*3+2*2+3*5=22 1*3+2*5+3*2=19 1*2+2*3+2*5=18
5+6+6=17 5+4+9=18
Dynamic Programming Approach
First, we will calculate the values
where j-i is equal to zero.
Now we will calculate the values
where j-i = 2
20
10
Recursive formulation
Example
Example
Example
Example
Example
Final Solution
Example
Example
Formal algorithm
Complexity analysis
Flow shop scheduling Problem
Single machine sequencing problem
Terminologies
Example
Two machine sequence problem
Informal algorithm
Example
Example
Example
Example
Final solution
Complexity Analysis
Glossary

Dynamic programming full notes.pptx