Data Structures & AlgorithmsHardProduct-company placement

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

  1. A. 336
  2. B. 380
  3. C. 528
  4. D. 248

Correct answer: D. 248

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 248. Left-to-right gives 336, right-to-left 380.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic