Data Structures & AlgorithmsHardGATE CS · Product-company placement

Five matrices have dimensions 10×15 , 15×3 , 3×5 , 5×15 , 15×15. What is the minimum number of scalar multiplications needed to compute their product?

  1. A. 1800
  2. B. 3600
  3. C. 4275
  4. D. 6975

Correct answer: A. 1800

m[i][j] = min over split k of m[i][k] + m[k+1][j] + p(i−1)·p(k)·p(j); the full chain costs 1800. Left-to-right gives 3600, right-to-left 4275.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic