Question
Four matrices and of dimensions , , and respectively can be multiplied in several ways with different number of total scalar multiplications. For example when multiplied as , the total number of scalar multiplications is . When multiplied as , the total number of scalar multiplications is .
If , and , then the minimum number of scalar multiplications needed is
Official answer and solution
- Official answer
- C
- From
- Official GATE 2011 answer key
Solution
Apply the dynamic programming Matrix Chain Multiplication algorithm to find the optimal parenthesization cost.
- Matrix dimensions are given by array , where matrix has dimension for .
- Chain length 2 costs:
- Chain length 3 costs:
- For :
- Split at 1:
- Split at 2:
- Minimum .
- For :
- Split at 2:
- Split at 3:
- Minimum .
- Chain length 4 ():
- Split at 1:
- Split at 2:
- Split at 3:
- The global minimum scalar multiplications needed is 19,000.
C
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2011 Computer Science and Information Technology (CS)
- Question
- 38 of 65, printed as CS Q.38
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.