Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Today’s Material Dynamic Programming – Chapter 15 –Introduction to Dynamic Programming –0-1 Knapsack Problem –Longest Common Subsequence –Chain Matrix.

Similar presentations


Presentation on theme: "1 Today’s Material Dynamic Programming – Chapter 15 –Introduction to Dynamic Programming –0-1 Knapsack Problem –Longest Common Subsequence –Chain Matrix."— Presentation transcript:

1 1 Today’s Material Dynamic Programming – Chapter 15 –Introduction to Dynamic Programming –0-1 Knapsack Problem –Longest Common Subsequence –Chain Matrix Multiplication

2 2 What’ Dynamic Programming (DP) Consider divide-and-conquer algorithms to problems –In certain optimization problems, there is often an overlap between subproblems (or subsubproblems) –Therefore, a classical recursive implementation solves the same problem over and over again, resulting in extremely bad running times Idea with DP is to simply save the result of a subproblem in a TABLE when you first encounter it & look up the result from this table for all encounters of the same problem

3 3 DP (continued) Since there should be a polynomial number of subproblems, we get a polynomial time algorithm –Also note that this is an example where we use more memory (save the results to subproblems in a TABLE) to reduce the running time of the algorithm –Recall Time-Space tradeoff Example: Fibonacci numbers & its recursive implementation –Polynomial number of subproblems –But the classical recursive implementation has exponential running time!

4 4 Designing DP Algorithms Substructure: –Decompose your problem into smaller and hopefully simpler subproblems –Express the solution of the original problem in terms of solutions for subproblems Bottom-up-Computation: –Combine solutions on smaller problems to solve larger problems Table-Structure: –Store the answers to the subproblems in a table. This is done because subproblem solutions are reused many times.

5 5 Elements of DP The most important question in designing a DP solution to a problem is how to set up the subproblem structure. This is called the formulation of the problem. DP is not applicable to all optimization problems. There are two important elements that a problem must have in order for DP to be applicable.

6 6 Elements of DP Optimal substructure (Principle of Optimality): –It states that for the global problem to be solved optimally, each subproblem should be solved optimally. –Not all optimization problems satisfy this. Sometimes it is better to lose a little on one subproblem in order to make a big gain on another. Polynomially Many SubProblems: –Total number of subproblems to be solved should be at most a polynomial number


Download ppt "1 Today’s Material Dynamic Programming – Chapter 15 –Introduction to Dynamic Programming –0-1 Knapsack Problem –Longest Common Subsequence –Chain Matrix."

Similar presentations


Ads by Google