retagged by
19,093 views
31 votes
31 votes

Assume that multiplying a matrix $G_1$ of dimension $ p \times q$ with another matrix $G_2$ of dimension $q \times r$ requires $pqr$ scalar multiplications. Computing the product of $n$ matrices $G_1G_2G_3 \dots G_n$ can be done by parenthesizing in different ways. Define $G_i G_{i+1}$ as an explicitly computed pair for a given paranthesization if they are directly multiplied. For example, in the matrix multiplication chain $G_1G_2G_3G_4G_5G_6$ using parenthesization $(G_1(G_2G_3))(G_4(G_5G_6)), G_2G_3$ and $G_5G_6$ are only explicitly computed pairs.

Consider a matrix multiplication chain $F_1F_2F_3F_4F_5$, where matrices $F_1, F_2, F_3, F_4$ and $F_5$ are of dimensions $ 2 \times 25, 25 \times 3, 3 \times 16, 16 \times 1 $ and $ 1 \times 1000$, respectively. In the parenthesization of $F_1F_2F_3F_4F_5$ that minimizes the total number of scalar multiplications, the explicitly computed pairs is/are

  1. $F_1F_2$ and $F_3F_4$ only
  2. $F_2F_3$ only
  3. $F_3F_4$ only
  4. $F_1F_2$ and $F_4F_5$ only
retagged by

6 Answers

Best answer
48 votes
48 votes
If we multiply anything with $F_{5}$ we will get much greater multiplication cost because $F_{5}$ is $1*1000$ matrix so $1000$ will play vital role in cost. So we will multiply $F_{5}$ at very last step.

So, here is the sequence giving minimal cost:

$(F_{1}(F_{2}(F_{3}F_{4})))(F_{5}) =  48 + 75 + 50 + 2000 =  2173$

Explicitly computed pairs is $(F_{3} F_{4} )$

Correct Answer: $C$
edited by
13 votes
13 votes

Matrix chain recurrence

$\large I^{st}\space part$

$M[1,2] = M[1,1] + M[2,2] + P_0P_1P_2 = 2\times 25\times 3= 150 $

$M[2,3] = P_1P_2P_3 = 25\times 3\times16=1200$

$M[3,4] = P_2P_3P_4 = 3\times 16\times1=48$

$M[4,5] = P_3P_4P_5 = 16\times 1\times1000=16000$

 

$\large II^{nd}\space part$

In $M[1,3] $ $M[1,2]$ is minimum so

$M[1,3] = M[1,2] + M[3,3] + P_0P_2P_3 = 150 + 2\times 3\times 16=243$

so minimum is $M[3,4]$ so

$M[2,4] = M[2,2] + M[3,4] + P_1P_2P_4 = 48 + 25\times3\times1 = 123 $

now compute further and $M[2,4] $ is minimum so

in $M[3,5]$ $M[3,4]$ is already minimum so

$M[3,5] = M[3,4] + M[5,5] + P_2P_4P_5 = 48 + 3\times 1\times 1000 = 3048 $

 

$\large III^{rd}\space part$

In previous part $M[2,4]$ is minimum

$M[1,4] = M[1,1] + M[2,4] + P_0P_1P_4 = 123 + 2\times 25\times 1=173 $

$M[2,4]$ is minimum so

$M[2,5] = M[2,4] + M[5,5] + P_1P_4P_5 = 123 + 25\times 1\times 1000= 25123$

 

$\large IV^{th}\space part$

$M[1,4]$ is minimum in previous part so

$M[1,5] = M[1,4] + M[5,5] + P_0P_4P_5 = 173 +2\times 1\times 1000 = 2173$

 

Now we can see-

$(F_1F_2F_3F_4F_5) \implies ((F_1F_2F_3F_4)F_5) \implies ((F_1(F_2F_3F_4))F_5) \implies((F_1(F_2(F_3F_4)))F_5)  $

 

So Option C is right one

5 votes
5 votes

Read comment of @akash.dinkar12 under @Digvijay Pandey 's answer and refer this 👇

Answer:

Related questions

38 votes
38 votes
5 answers
1
gatecse asked Feb 14, 2018
22,227 views
Consider the weights and values of items listed below. Note that there is only one unit of each item.$$\begin{array}{|c|c|c|}\hline \textbf{Item number} & \textbf{Weigh...
35 votes
35 votes
9 answers
2
gatecse asked Feb 14, 2018
17,625 views
Consider the following undirected graph $G$:Choose a value for $x$ that will maximize the number of minimum weight spanning trees (MWSTs) of $G$. The number of MWSTs of $...
35 votes
35 votes
7 answers
3