GATE Computer ScienceVery hardGATE CS (PYQ pattern)

Matrices A1 to A6 have dimensions 5×40, 40×10, 10×30, 30×8, 8×25 and 25×6. The minimum number of scalar multiplications needed to compute A1A2A3A4A5A6 is:

  1. A. 6450
  2. B. 8040
  3. C. 6140
  4. D. 6760

Correct answer: C. 6140

The matrix-chain DP m[i][j] = min over k of m[i][k] + m[k+1][j] + p(i−1)·p(k)·p(j) gives 6140 for the full chain. Multiplying strictly left to right costs 6450, and right to left costs 8040.

More Algorithms questions

Exams that ask this topic