Skip to content
GATEiit

GATE CSE 2018 Q41: Explicitly computed pairs in optimal matrix chain parenthesization of five matrices

Syllabus topic: Algorithm design techniques: greedy, dynamic programming and divide-and-conquer

Question

Assume that multiplying a matrix G1 of dimension p×q with another matrix G2 of dimension q×r requires pqr scalar multiplications. Computing the product of n matrices G1G2G3…Gn can be done by parenthesizing in different ways. Define GiGi+1 as an explicitly computed pair for a given paranthesization if they are directly multiplied. For example, in the matrix multiplication chain G1G2G3G4G5G6 using parenthesization (G1(G2G3))(G4(G5G6)), G2G3 and G5G6 are the only explicitly computed pairs.

Consider a matrix multiplication chain F1F2F3F4F5, where matrices F1,F2,F3,F4 and F5 are of dimensions 2×25, 25×3, 3×16, 16×1 and 1×1000, respectively. In the parenthesization of F1F2F3F4F5 that minimizes the total number of scalar multiplications, the explicitly computed pairs is/are

Try it: multiple choice: exactly one correct option

Select one option
Wrong answer costs 2/3 mark in GATE.
Show answer and explanation

Answer: C (official GATE 2018 final answer key)

Concept used: Matrix chain multiplication dynamic programming: the optimal split points determine which adjacent pairs are multiplied directly.

Concept notes

Loading notes…

First step: Notice that F4 has a column dimension of 1, so collapsing F1…F4 down to a 2×1 matrix before multiplying by F5 is cheap; run the DP (or compare candidate splits) for F1…F4.

Full step-by-step solution

Loading…

Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.

More questions on Algorithm design techniques: greedy, dynamic programming and divide-and-conquer

Every PYQ on this topic →

Share this question

WhatsAppDownload image

Source: official GATE 2018 CS question paper and final answer key, organised by IIT Guwahati. Question paper · Answer key