Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 5
Dynamic Programming
Design and Analysis
Introduction • 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 is to simply store the results of subproblems, so that we do not have to re-compute them when needed later. This simple optimization reduces time complexities from exponential to polynomial. • For example, if we write simple recursive solution for Fibonacci Numbers, we get exponential time complexity and if we optimize it by storing solutions of subproblems, time complexity reduces to linear. Introduction • Dynamic programming is defined as a computer programming technique where an algorithmic problem is first broken down into sub-problems, the results are saved, and then the sub-problems are optimized to find the overall solution — which usually has to do with finding the maximum and minimum range of the algorithmic query Steps of Dynamic Programming Approach • Characterize the structure of an optimal solution. • Recursively define the value of an optimal solution. • Compute the value of an optimal solution, typically in a bottom-up fashion. • Construct an optimal solution from the computed information. Examples • Fibonacci number series • Knapsack problem • Tower of Hanoi • All pair shortest path by Floyd-Warshall and Bellman Ford • Shortest path by Dijkstra • Project scheduling • Matrix Chain Multiplication