Skip to content

ISRO Scientist/Engineer CSE 2020Algorithms › Not yet assigned to a topic

ISRO Scientist/Engineer CSE 2020 PYQ: Consider product of three matrices $M_1,M_2$ and $M_3$ having $w$ rows and $x$ columns, $x$ rows and $y$…

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. A
    Always take the same time
  2. B
    $(1/x +1/z)<(1/w+1/y)$
    Correct answer
  3. C
    $x>y$
  4. D
    $(w+x)>(y+z)$

Answer

(B) $(1/x +1/z)<(1/w+1/y)$

Approach

Compare the number of scalar multiplications required by the two parenthesizations of the matrix chain product. The cost of $(M_1M_2)M_3$ is $wxy + wyz$ and the cost of $M_1(M_2M_3)$ is $xyz + wxz$. The first is faster when $wxy + wyz < xyz + wxz$. Dividing both sides by the positive quantity $wxyz$ yields the condition in option B.

Reviewed by ISRO IQ Editorial Team.