Data Structures & AlgorithmsHardGATE CS · Product-company placement

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

  1. A. 2700
  2. B. 900
  3. C. 1350
  4. D. 2910

Correct answer: B. 900

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 900. Left-to-right gives 2700, right-to-left 1350.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic