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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
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 programming algorithm on page 69, as well as what each of the letters represents.

2. For figure 2.16, are we supposed to compute it row by row or collum by column by column, and why?

 

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: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
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). ☐
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
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education