We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
UNIT-IV DYNAMIC PROGRAMMING
DESIGN AND ANALYSIS OF ALGORITHMS
UNIT-IV
Syllabus: Dynamic Programming: All - Pairs Shortest Paths, Single – Source
Shortest paths General Weights, String Edition, 0/1 Knapsack, Reliability Design
Dynamic programming: It is typically applied to the optimization problems. It
is invented by a U.S. Mathematician Richard Bellman in 1950. In the word dynamic programming, the word programming stands for planning and it does not mean by computer programming.
Dynamic programming is a technique for solving problems with
overlapping sub-problems. In the method each sub-problem is solved only once. The result of each sub-problem is recorded in a table from which we can obtain a solution to the original problem.
Control Abstraction (OR) The General Method (OR) The General
Principle of Dynamic programming:
Dynamic programming is typically applied to the optimization problems.
For each given problem, we may get any number of solutions we seek for optimal solution (i.e., minimum value or maximum value solution). And such optimal solution becomes the solution to the given problem.
Steps of DP:
DP design involves 4 major steps:
1. Characterize the structure of optimal solution. That means develop a
mathematical notation that can express any solution and sub-solution for the given problem. 2. Recursively, define the value of an optimal solution.
3. By using the bottom up technique compute the value of optimal
solution. For that you have to develop a recurrence relation that relates a solution to its sub-solutions, using the mathematical notation of step1. 4. Compute an optimal solution from computed information. Principle of Optimality:
The DP algorithm obtains the solution using the principle of optimality.
The principle of optimality states that “in an optimal sequence of decisions or choices, each sub-sequence must also be optimal”. When it is not possible to apply the principle of optimality, it is almost impossible to obtain the solution using the dynamic programming approach. Example: Finding the shortest path in a given graph uses the principle of optimality.
Applications of Dynamic Programming:
The following are the some applications of DP:
1. All Pairs Shortest Path.
2. Single Source Shortest path with general weights.
Difference between Divide and Conquer & Greedy method:
Divide and conquer(DAC) Dynamic Programming(DP)
1. Divide the given problem into many 1. In dynamic programing, many sub problems. These sub-problems are decision sequences are generated solved independently. Finally all the and all the overlapping sub- solutions of sub-problems are instances are considered. collected together to get the solution to the given problem. 2. In this method, duplicate sub- 2. In this method, duplicate sub- solutions are neglected. solutions are avoided totally. 3. It is less efficient because of rework 3. It is less efficient than DAC. on solutions. 4. It uses top down approach. 4. It uses bottom up approach. 5. DAC splits its input at specific 5. DP splits its input at every deterministic points usually in the possible split points rather than at a middle. particular point. After trying all split points it determines which split point is optimal.
Difference between Greedy method & Dynamic Programming:
GREEDY METHOD(GM) Dynamic Programming(DP)
1. Greedy Method is used for 1. Dynamic programing is also used obtaining optimal solution. for obtaining optimal solution.
2. In this method, a set of feasible 2. In this method, there is no special
solutions are being calculated and pick set of feasible solutions. up the optimal solution. 3. In this method, the optimal 3. DP considers all possible selection is without revising previously sequences in order to obtain the generated solutions. optimal solution. 4. In this method, there is no such 4. In this method, there is guarantee guarantee of getting optimal solution. of getting optimal solution using principle of optimality.
Indranil Barman, SPE, Texas A&M U,, Arun K, Sharma, SPE, Mobil E&P US Inc., Richard F. Walker, Spe, Mobil E&P US Inc. and Akhil Datta-Gupta, SPE, Texas A&M U