





















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






















Optimizations problem?
-^
Steps in Development of Dynamic Algorithms
-^
Why dynamic in optimization problem?
-^
Introduction to Catalan numbers
-^
Chain-Matrix Multiplication
-^
Problem Analysis– Brute Force approach– Time Complexity
-^
Conclusion
Characterize the structure of an optimal solution
Recursively define the value of an optimalsolution
Compute the value of an optimal solution in abottom-up fashion
Construct an optimal solution from computedinformationNote: Steps 1-3 form the basis of a dynamicprogramming solution to a problem. Step 4 canbe omitted only if the value of an optimalsolution is required.
Dynamic programming, like divide and conquermethod, solves problems by combining thesolutions to sub-problems.
-^
Divide and conquer algorithms:• partition the problem into independent sub-problem• Solve the sub-problem recursively and• Combine their solutions to solve the original problem
-^
In contrast, dynamic programming is applicablewhen the sub-problems are not independent.
-^
Dynamic programming is typically applied tooptimization problems.
Objective:•^
Find C(n), the numberof ways to computeproduct x
1
. x
2
…. x
.n^
n
multiplication order
(x
1
· x
(x
1
· (x
2
· x
((x
1
· x
) · x 2
(x
1
· (x
2
· (x
3
· x
(x
1
· ((x
2
· x
) · x 3
((x
1
· x
) · (x 2
3
· x
((x
1
· (x
2
· x
)) · x 3
(((x
1
· x
) · x 2
) · x 3
Recursive equation:
where is the last multiplication?
k n C k C
n k
n C
. (^21)
2 1 ) (^
^
n n
n
n C
(^2) / 4 3
) (^
n
n C
n
n for 4
1)- C(n)C(n
Catalan numbers:Asymptotic
:
Given a sequence of matrices, we want to find amost efficient way to multiply these matrices
-^
It means that problem is not actually to perform themultiplications, but decide the order in which thesemust be multiplied to reduce the cost.
-^
This problem is an optimization type which can besolved using dynamic programming.
-^
The problem is not limited to find an efficient way ofmultiplication of matrices, but can be used to beapplied in various purposes.
-^
But how to transform the original problem into chainmatrix multiplication, this is another issue, which iscommon in systems modeling.
If these matrices are all square and of same size,the multiplication order will not affect the total cost.
-^
If matrices are of different sizes but compatible formultiplication, then order can make big difference.
-^
Brute Force approach– The number of possible multiplication orders are
exponential in n, and so trying all possible ordersmay take a very long time.
Dynamic Programming– To find an optimal solution, we will discuss it
using dynamic programming to solve it efficiently.
If we wish to multiply two matrices:A = a[i, j]
p, q
and B = b[i, j]
q, r
Now if C = AB then order of C is p x r.
-^
Since in each entry c[i, j], there are q number ofscalar of multiplications
-^
Total number of scalar multiplications incomputing C = Total entries in C x Cost ofcomputing a single entry = p. r. q
-^
Hence the computational cost of AB = p. q. r
There are five ways to parenthesize this product
-^
Cost of computing the matrix product may vary,depending on order of parenthesis.
-^
All possible ways of parenthesizing
1
2
3
1
2
1
3
1
2
1