The GATE Grind

GATE 2016 CS (CS2) – Question 48

Algorithms · Dynamic Programming · 2 marks · Numerical answer

Matrices A₁,A₂,A₃,A₄ have dimensions 10×5, 5×20, 20×10 and 10×5. Find the minimum scalar-multiplication count for A₁A₂A₃A₄ using ordinary matrix multiplication.

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 1500.0 to 1500.0

Explanation

Pair costs are m₁₂=1000, m₂₃=1000, m₃₄=1000. Matrix-chain dynamic programming gives m₁₃=min(1000+500,1000+2000)=1500 and m₂₄=min(1000+500,1000+250)=1250. The three final splits cost 1500,2500,2000. Thus A₁((A₂A₃)A₄) is optimal, costing 1000+250+250=1500.

More Dynamic Programming questions

All Dynamic Programming questions →