Data Structures & AlgorithmsHardGATE CS

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

  1. A. 860
  2. B. 555
  3. C. 1155
  4. D. 510

Correct answer: D. 510

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 510. Left-to-right gives 860, right-to-left 555.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic