Mix Mi+1 Clearly, mij= = {MIN (my + mx + 1) + F1-1³ ³), if i=j if j>i (2.9) ish i, is the minimum, taken over all possible values of k between i and j- 1, of the sum of these three terms. The dynamic programming approach calculates the m;;'s in order of in- creasing difference in the subscripts. We begin by calculating m¡ for all i, then m₁,+ for all i, next mi,i+2, and so on. In this way, the terms m₁k and mk+1,j in (2.9) will be available when we calculate mij. This follows since j - i must be strictly greater than either of k-i and j― (k+1) if k is in the range i≤ k
Mix Mi+1 Clearly, mij= = {MIN (my + mx + 1) + F1-1³ ³), if i=j if j>i (2.9) ish i, is the minimum, taken over all possible values of k between i and j- 1, of the sum of these three terms. The dynamic programming approach calculates the m;;'s in order of in- creasing difference in the subscripts. We begin by calculating m¡ for all i, then m₁,+ for all i, next mi,i+2, and so on. In this way, the terms m₁k and mk+1,j in (2.9) will be available when we calculate mij. This follows since j - i must be strictly greater than either of k-i and j― (k+1) if k is in the range i≤ k
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 7SA
Related questions
Question
My algorithms professor is asking us to learn chain matrix multiplication. I have multiple questions.
1. I need help understanding the dynamic
2. For figure 2.16, are we supposed to compute it row by row or collum by column by column, and why?

Transcribed Image Text:Mix Mi+1
Clearly,
mij=
= {MIN (my + mx + 1) + F1-1³ ³),
if i=j
if j>i
(2.9)
ish<j
The term m is the minimum cost of evaluating M' = M; × M¡+1 × · · ·× Mk.
The second term, m+1, is the minimum cost of evaluating
MM+ Mk+2 ×···× M;
The third term is the cost of multiplying M' by M". Note that M' is an ri-1 Xrk
matrix and M" is an rk X r; matrix. Equation (2.9) states that m₁;, j> i, is the
minimum, taken over all possible values of k between i and j- 1, of the sum
of these three terms.
The dynamic programming approach calculates the m;;'s in order of in-
creasing difference in the subscripts. We begin by calculating m¡ for all i,
then m₁,+ for all i, next mi,i+2, and so on. In this way, the terms m₁k and mk+1,j
in (2.9) will be available when we calculate mij. This follows since j - i must
be strictly greater than either of k-i and j― (k+1) if k is in the range i≤
k<j. The algorithm is given below.
Algorithm 2.5. Dynamic programming algorithm for computing the minimum
cost order of multiplying a string of n matrices, M₁ × M2 × × Mn-
Input. Fo, F., where ;-1 and r, are the dimensions of matrix M₁.
Output. The minimum cost of multiplying the M's. assuming pqr operations
are required to multiply a p xq matrix by a q× r matrix.
Method. The algorithm is shown in Fig. 2.15. ☐
Example 2.8. Applying the algorithm to the string of four matrices in (2.8),
where are 10, 20, 50. 1. 100. would result in computing the values
for the m's shown in Fig. 2.16. Thus the minimum number of operations

Transcribed Image Text:begin
- cici
1.
for
2.
for
3.
for
4.
tvi
5.
6.
write min
end
EPILOGUE 69
until n do mi¡ - 0:
until 1 - 1 do
begin
until n - / do
j←i+l;
-
mij MIN (mik+m+1,j + "';-1 * "k; * 1;)
end;
isk<j
Fig. 2.15. Dynamic programming algorithm for ordering matrix multiplications.
m₁₁ = 0
M22 0
=
m33 0
==
m44 = 0
m12 =
10,000
m23
==
1000
=
M3+ 5000
m13
= 1200
m24 = 3000
==
m14 2200
Fig. 2.16. Costs of computing products M; × Mi+1 ×·
× Mj.
required to evaluate the product is 2200. An order in which the multiplica-
tions may be done can be determined by recording, for each table entry, a
value of k which gives rise to the minimum seen in (2.9). ☐
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Recommended textbooks for you

C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning

C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr

Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole

C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning

C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr

Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole

Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning

LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.
Computer Science
ISBN:
9781337569798
Author:
ECKERT
Publisher:
CENGAGE L
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L