GATE / CS ARCHIVE

GATE CSE 2011 / QUESTION 38

Matrix-chain multiplication optimum

Algorithms · Dynamic Programming · Full GATE CSE 2011 paper

GATE 2011, Q38 2 marks · MCQ
Report issue

Dynamic Programming

Question 38, GATE 2011: Four matrices M1,M2,M3,M4 have dimensions 10×100,100×20,20×5,5×80. Multiplication of an a×b matrix by a b×c matrix costs abc scalar multiplications. What is the minimum total for their ordered product over all parenthesizations?

(A) 248000
(B) 44000
(C) 19000
(D) 25000
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Step through it (8 steps)

For dimensions 10, 100, 20, 5, 80, the five full parenthesizations have costs 25000 for(((AB)C)D), 19000 for((A(BC))D), 44000 for((AB)(CD)), 130000 for(A((BC)D)) and 248000 for(A(B(CD))). The minimum is 19000, attained by BC costing 100×20×5=10000, then A(BC) costing 10×100×5=5000, then the final product costing 10×5×80=4000. Thus C.

Label the matrices A,B,C,D. Dimensions of intermediate results matter: BC is 100×5, A(BC) is 10×5, and the final product is 10×80. Multiplying the dimensions of each operation yields the stated 10000+5000+4000 optimum. Checking all five full binary parenthesizations proves that this is a global minimum, not merely a good greedy choice. For example, doing AB first already costs 20000 before the remaining work, exceeding the optimum by itself.

Original paper, page 10 · Answer key