edited by
2,822 views
3 votes
3 votes

Consider product of three matrices $M_1,M_2$ and $M_3$ having $w$ rows and $x$ columns, $x$ rows and $y$ columns, and $y$ rows and $z$ columns. Under what condition will it take less time to compute the product as $(M_1M_2)M_3$ than to compute $M_1(M_2M_3)$ ?

  1. Always take the same time
  2. $(1/x +1/z)<(1/w+1/y)$
  3. $x>y$
  4. $(w+x)>(y+z)$
edited by

3 Answers

8 votes
8 votes
$\underline{\textbf{Answer:}\Rightarrow}\;\mathbf{b.}$

$\underline{\textbf{Explanation:}\Rightarrow}$

$\mathrm{M_{1_{w\times x}} M_{2_{x\times y}} M_{3_{y\times z}}}$

$\text{Cost of } \;\mathrm{(M_1M_2)M_3\; = wxy+ wyz}$

while $\text{Cost of } \; \mathrm{M_1(M_2M_3)\; = xyz + wxz}$

Now, The time taken by $(M_1M_2)M_3$ will be less than $\mathrm{M_1(M_2M_3)}$, when

$\mathrm{wxy + wyz < xyz + wxz}$

Divide both sides with $\mathbf{wxyz}$, we will get:

$\mathrm{\dfrac{1}{z}+ \dfrac{1}{x} < \dfrac{1}{w}+ \dfrac{1}{y} }$
edited by
1 votes
1 votes

Option b is correct


Number of multiplication for $(M{_{1}}M{_{2}})M{_{3}}= wxy+wyz$

Number of multiplication for

$M{_{1}}(M{_{2}}M{_{3}})= xyz+wxz$

According to question:

$wxy+wyz < xyz+wxz$

Divide by $wxyz$ on both the sides we get

$\frac{1}{z} +\frac{1}{x} < \frac{1}{w} + \frac{1}{y}$

Answer:

Related questions

10 votes
10 votes
3 answers
1
Satbir asked Jan 13, 2020
8,754 views
What is the complexity of the following code?sum=0; for(i=1;i<=n;i*=2) for(j=1;j<=n;j++) sum++;Which of the following is not a valid string?$O(n^2)$$O(n\log\ n)$$O(n)$$O(...
5 votes
5 votes
2 answers
2
Satbir asked Jan 13, 2020
4,612 views
Huffman tree is constructed for the following data :$\{A,B,C,D,E\}$ with frequency $\{0.17,0.11,0.24,0.33\ \text{and} \ 0.15 \}$ respectively. $100\ 00\ 01101$ is decoded...
5 votes
5 votes
5 answers
3
Satbir asked Jan 13, 2020
7,817 views
If an array $A$ contains the items $10,4,7,23,67,12$ and $5$ in that order, what will be the resultant array $A$ after third pass of insertion sort?$67,12,10,5,4,7,23$$4,...
7 votes
7 votes
2 answers
4
Satbir asked Jan 13, 2020
3,239 views
In linear hashing, if blocking factor $bfr$, loading factor $i$ and file buckets $N$ are known, the number of records will be$cr= i+bfr+N$$r=i-bfr-N$$r=i+bfr-N$$r=i ^{\as...