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:
- A. 6450
- B. 8040
- C. 6140
- 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
- A text uses 8 symbols with frequencies 5, 9, 12, 13, 16, 45, 3 and 7. If a Huffman code is built, the total number of bits needed for the…
- A 0/1 knapsack has capacity 50 and items given as (value, weight): (60, 10), (100, 20), (120, 30), (75, 25). The maximum total value is:
- Which of the following statements are correct? (I) 2-SAT can be solved in polynomial time. (II) Subset-sum has a pseudo-polynomial…
- An AVL tree is a binary search tree in which the heights of the two subtrees of every node differ by at most 1. Taking the height of a…
- A B-tree has minimum degree t = 3 (every node other than the root holds between t − 1 and 2t − 1 keys; the root holds at least 1 key) and…
- A DAG has vertices 1 to 8 and edges 1→3, 2→3, 3→4, 3→5, 2→6, 6→5, 4→7, 5→7, 8→6, 1→8. How many different topological orderings does it have?