GATE CS 2018 Set 1 — Question 41
Go beyond PYQs with Success TrackerAI-powered personalised practice and doubt support. Unlimited practice on eligible plans; AI usage limits apply.MCQ+2 / -0.67MediumMatrix Chain MultiplicationDynamic ProgrammingAlgorithms
Algorithms → Dynamic Programming → Matrix Chain Multiplication
Last updated
Question
Assume that multiplying a matrix of dimension with another matrix of dimension requires scalar multiplications. Computing the product of n matrices can be done by parenthesizing in different ways. Define as an explicitly computed pair for a given paranthesization if they are directly multiplied. For example, in the matrix multiplication chain using parenthesization , and are the only explicitly computed pairs.Consider a matrix multiplication chain , where matrices and are of dimensions 2x25, 25x3, 3x16, 16x1 and 1x1000, respectively. In the parenthesization of that minimizes the total number of scalar multiplications, the explicitly computed pairs is/are
Correct answer
(C) F₃F₄ only
Solution
This is a matrix chain multiplication problem. We need to find the optimal parenthesization for the product .The dimensions of the matrices are:
We use dynamic programming. Let be the minimum cost to compute the product .Length 2:
The parenthesization for was found to be .
So the full optimal parenthesization is .According to the problem definition, an "explicitly computed pair" is a pair of adjacent original matrices that are directly multiplied.
In the optimal parenthesization , the first multiplication performed is . This is a pair of adjacent original matrices.
The subsequent multiplications are:
Therefore, the only explicitly computed pair is .
We use dynamic programming. Let be the minimum cost to compute the product .Length 2:
- . Split at , i.e., .
- . Split at , i.e., .
- . Split at , i.e., .
- . Split at , i.e., , where is . So, .
- . We need .
- .
- Cost for in is .
- .
- .
- .
The parenthesization for was found to be .
So the full optimal parenthesization is .According to the problem definition, an "explicitly computed pair" is a pair of adjacent original matrices that are directly multiplied.
In the optimal parenthesization , the first multiplication performed is . This is a pair of adjacent original matrices.
The subsequent multiplications are:
Therefore, the only explicitly computed pair is .
Continue learning with Success Tracker
A step still unclear? Work through it with support
Use Success Tracker to ask about the reasoning, then try another GATE CS question to check your understanding.
AI-powered practice· Unlimited practice on eligible plans
- PYQs with solutions
- Attempt available previous-year questions, then compare your reasoning with the worked solution. Coverage varies by stream.
- Practice that adapts
- Choose a topic, work on weaker areas and bookmark questions to revisit. Your attempts feed your progress tracking.
- AI doubt support
- Ask follow-up questions about a step or concept while practising, instead of stopping at the final answer.
Unlimited practice is available on eligible plans. Free practice and AI usage have limits; check the current plan allowances before choosing.
This page stays readable without an account. AI responses can be wrong; check them against the solution and source material.
More questions on Dynamic Programming
2026 Set 1 Q17Consider the following recurrence relations: For all ,…2026 Set 2 Q24Consider the following functions, where is a positive integer.…2026 Set 2 Q25Which of the following can be recurrence relation(s) corresponding to an algorithm with time…2026 Set 2 Q32Consider an array . Suppose the merge sort algorithm is…2026 Set 2 Q37Let be a weighted directed acyclic graph with edges and vertices. Given and a…