GATE Computer ScienceVery hardGATE CS (PYQ pattern)
Matrices A₁ … A₇ have dimensions 5×12, 12×7, 7×20, 20×4, 4×15, 15×9 and 9×6, i.e. the dimension array p = [5, 12, 7, 20, 4, 15, 9, 6]. What is the minimum number of scalar multiplications to compute A₁A₂…A₇?
- A. 2765
- B. 1996
- C. 3354
- D. 2210
Correct answer: B. 1996
The matrix-chain DP gives m[1][7] = 1996. Multiplying strictly left to right costs 2765 and strictly right to left costs 3354, so neither fixed order is optimal.
More Algorithms questions
- A recursive matrix-chain function without memoisation, cost(i, j), returns 0 when i = j and otherwise calls cost(i, k) and cost(k+1, j)…
- A 0/1 knapsack has capacity 26 and items (weight, value): (12, 24), (7, 13), (11, 23), (8, 15), (9, 16), (6, 11). The maximum total value…
- A coin system has denominations {1, 5, 10, 20, 25}. The greedy algorithm (always take the largest coin that fits) first gives a…
- For the coin system {1, 5, 12, 25}, among the amounts 1, 2, …, 100, for how many amounts does the greedy algorithm use more coins than the…
- Using unlimited coins of denominations 2, 5, 7 and 10 (order does not matter), how many ways are there to pay exactly 40 using at most 6…
- In the array [2, 5, 3, 7, 11, 8, 10, 13, 6, 9, 4, 12] the longest strictly increasing subsequences have length 6. How many different…