retagged by
22,711 views
42 votes
42 votes
Let $A_{1}, A_{2}, A_{3}$ and $A_{4}$ be four matrices of dimensions $10 \times 5, 5 \times 20, 20 \times 10$ and $10 \times 5$, respectively. The minimum number of scalar multiplications required to find the product $A_{1}A_{2}A_{3}A_{4}$ using the basic matrix multiplication method is _________.
retagged by

7 Answers

Best answer
47 votes
47 votes

The answer is $1500$.

Matrix Parenthesizing :  $A_1 ((A_2 A_3) A_4)$

Check my solution below, using dynamic programming $$\begin{array}{|l|l|}\hline A_{1} &A_{2} & A_{3} &A_{4}\\\hline 10 \times 5 & 5 \times 20 & 20 \times 10 & 10\times 5  \\\hline \end{array}$$

  • $A_{12} = 10 \times 5 \times 20 =1000$
  • $A_{23} = 5 \times 20 \times 10 =1000$
  • $A_{34} = 20 \times 10 \times 5 =1000$

$$A_{13}=min\left\{\begin{matrix} A_{12} + A_{33}+ 5 \times 20 \times 10 = 2000\\ A_{11} + A_{23} + 10 \times 5 \times 10 = 1500 \end{matrix}\right.$$

$$A_{24}=min\left\{\begin{matrix} A_{23} + A_{44}+ 5 \times 10 \times 5 = 1250\\ A_{22} + A_{34} + 5 \times 20 \times 5 = 1500 \end{matrix}\right.$$

$$A_{14}=min\left\{\begin{matrix} A_{11} + A_{24}+ 10 \times 5 \times 5 = 1500\\ A_{12} + A_{34} + 10 \times 20\times 5 \geqslant 2000\\ A_{13}+A_{44} + 10 \times 20\times 5 = 2000 \end{matrix}\right.$$

Answer is 1500.

edited by
9 votes
9 votes

$A_{10\times 5}|A_{5\times 20}|A_{20\times 10}|A_{10\times 5}$

$P_{0}\times P_{1}|P_{1}\times P_{2}|P_{2}\times P_{3}|P_{3}\times P_{4}$

 

$(1,1)=0$ $(2,2)=0$ $(3,3)=0$ $(4,4)=0$
$(1,2)=1000$ $(2,3)=1000$ $(3,4)=1000$ $\times$
$(1,3)=1500$ $(2,4)=1250$ $\times$ $\times$
$(1,4)=1500$ $\times$ $\times$ $\times$

$A_{13}=min\left\{\begin{matrix} A_{12} + A_{33}+ 10 \times 20 \times 10(P_{0}\times P_{2}\times P_{3}) = 3000\\ A_{11} + A_{23} + 10 \times 5 \times 10(P_{0}\times P_{1}\times P_{3}) = 1500 \end{matrix}\right.$

$A_{24}=min\left\{\begin{matrix} A_{23} + A_{44}+ 5 \times 10 \times 5(P_{1}\times P_{3}\times P_{4}) = 1250\\ A_{22} + A_{34} + 5 \times 20 \times 5(P_{1}\times P_{2}\times P_{4}) = 1500 \end{matrix}\right.$

$A_{14}=min\left\{\begin{matrix} A_{11} + A_{24}+ 10 \times 5 \times 5(P_{0}\times P_{1}\times P_{4}) = 1500\\ A_{12} + A_{34} + 10 \times 20\times 5(P_{0}\times P_{2}\times P_{4}) = 3000\\ A_{13}+A_{44} + 10 \times 10\times 5(P_{0}\times P_{3}\times P_{4}) = 2000 \end{matrix}\right.$

8 votes
8 votes
Minimum number of scalar multiplications required is 1500.

A1((A2A3)A4) is the order, where scalar multiplications are minimum here and is 1500
Answer:

Related questions

21 votes
21 votes
4 answers
1
Akash Kanase asked Feb 12, 2016
7,321 views
The Floyd-Warshall algorithm for all-pair shortest paths computation is based onGreedy paradigm.Divide-and-conquer paradigm.Dynamic Programming paradigm.Neither Greedy no...
0 votes
0 votes
1 answer
3