Download presentation

Presentation is loading. Please wait.

Published byDanna Grandin Modified over 3 years ago

1
Algorithm Design Methodologies Divide & Conquer Dynamic Programming Backtracking

2
Optimization Problems Dynamic programming is typically applied to optimization problems In such problems, there are many feasible solutions We wish to find a solution with the optimal (maximum or minimum value) Examples: Minimum spanning tree, shortest paths

3
Matrix Chain Multiplication To multiply two matrices A (p by q) and B (q by r) produces a matrix of dimensions (p by r) and takes p * q * r “simple” scalar multiplications

4
Matrix Chain Multiplication Given a chain of matrices to multiply: A1 * A2 * A3 * A4 we must decide how we will paranthesize the matrix chain: –(A1*A2)*(A3*A4) –A1 * (A2 * (A3*A4)) –A1 * ((A2*A3) * A4) –(A1 * (A2*A3)) * A4 –((A1*A2) * A3) * A4

5
Matrix Chain Multiplication We define m[i,j] as the minimum number of scalar multiplications needed to compute A i..j Thus, the cheapest cost of multiplying the entire chain of n matrices is A [1,n] If i <> j, we know m[i,j] = m[i,k] + m[k+1,j] + p[i-1]*p[k]*p[j] for some value of k [i,j)

6
Elements of Dynamic Programming Optimal Substructure Overlapping Subproblems

7
Optimal Substructure This means the optimal solution for a problem contains within it optimal solutions for subproblems. For example, if the optimal solution for the chain A1*A2*…*A6 is ((A1*(A2*A3))*A4)*(A5*A6) then this implies the optimal solution for the subchain A1*A2*….*A4 is ((A1*(A2*A3))*A4)

8
Overlapping Subproblems Dynamic programming is appropriate when a recursive solution would revisit the same subproblems over and over In contrast, a divide and conquer solution is appropriate when new subproblems are produced at each recurrence

Similar presentations

OK

UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels Fall, 2002 Lecture 1 (Part 3) Tuesday, 9/3/02 Design Patterns for Optimization.

UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels Fall, 2002 Lecture 1 (Part 3) Tuesday, 9/3/02 Design Patterns for Optimization.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on 555 timer projects Ppt on atomic structure class 11 Ppt on beer lambert law problems Ppt on industrial revolution Ppt on kinetic theory of matter/gas laws Ppt on different types of dance forms productions Ppt on child labour in world Ppt on any one mathematician byron Ppt on national democratic alliance Ppt on allergic contact dermatitis