GateAI
Algorithm Design Techniques

GATE CSE 2011 · Q38

MCQ2 marksMedium

Time

Four matrices M1M_1, M2M_2, M3M_3 and M4M_4 of dimensions p×qp \times q, q×rq \times r, r×sr \times s and s×ts \times t respectively can be multiplied in several ways with different number of total scalar multiplications. For example when multiplied as ((M1×M2)×(M3×M4))((M_1 \times M_2) \times (M_3 \times M_4)), the total number of scalar multiplications is pqr+rst+prtpqr + rst + prt. When multiplied as (((M1×M2)×M3)×M4)(((M_1 \times M_2) \times M_3) \times M_4), the total number of scalar multiplications is pqr+prs+pstpqr + prs + pst. If p=10p = 10, q=100q = 100, r=20r = 20, s=5s = 5, and t=80t = 80, then the minimum number of scalar multiplications needed is

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: C) 19000

Algorithm Design Techniques

We use the dynamic programming algorithm for Matrix Chain Multiplication. Given dimensions array d=[d0,d1,d2,d3,d4]=[10,100,20,5,80]d = [d_0, d_1, d_2, d_3, d_4] = [10, 100, 20, 5, 80]:

  • M1:10×100M_1: 10 \times 100

  • M2:100×20M_2: 100 \times 20

  • M3:20×5M_3: 20 \times 5

  • M4:5×80M_4: 5 \times 80

Chain Length 2:

  • m[1,2]=d0d1d2=10×100×20=20000m[1, 2] = d_0 d_1 d_2 = 10 \times 100 \times 20 = 20000

  • m[2,3]=d1d2d3=100×20×5=10000m[2, 3] = d_1 d_2 d_3 = 100 \times 20 \times 5 = 10000

  • m[3,4]=d2d3d4=20×5×80=8000m[3, 4] = d_2 d_3 d_4 = 20 \times 5 \times 80 = 8000

Chain Length 3:

  • For m[1,3]m[1, 3]:

    • k=1k = 1: m[1,1]+m[2,3]+d0d1d3=0+10000+10×100×5=15000m[1, 1] + m[2, 3] + d_0 d_1 d_3 = 0 + 10000 + 10 \times 100 \times 5 = 15000

    • k=2k = 2: m[1,2]+m[3,3]+d0d2d3=20000+0+10×20×5=21000m[1, 2] + m[3, 3] + d_0 d_2 d_3 = 20000 + 0 + 10 \times 20 \times 5 = 21000

    •   ⟹  m[1,3]=15000\implies m[1, 3] = 15000

  • For m[2,4]m[2, 4]:

    • k=2k = 2: m[2,2]+m[3,4]+d1d2d4=0+8000+100×20×80=168000m[2, 2] + m[3, 4] + d_1 d_2 d_4 = 0 + 8000 + 100 \times 20 \times 80 = 168000

    • k=3k = 3: m[2,3]+m[4,4]+d1d3d4=10000+0+100×5×80=50000m[2, 3] + m[4, 4] + d_1 d_3 d_4 = 10000 + 0 + 100 \times 5 \times 80 = 50000

    •   ⟹  m[2,4]=50000\implies m[2, 4] = 50000

Chain Length 4 (m[1,4]m[1, 4]):

  • k=1k = 1: m[1,1]+m[2,4]+d0d1d4=0+50000+10×100×80=130000m[1, 1] + m[2, 4] + d_0 d_1 d_4 = 0 + 50000 + 10 \times 100 \times 80 = 130000

  • k=2k = 2: m[1,2]+m[3,4]+d0d2d4=20000+8000+10×20×80=44000m[1, 2] + m[3, 4] + d_0 d_2 d_4 = 20000 + 8000 + 10 \times 20 \times 80 = 44000

  • k=3k = 3: m[1,3]+m[4,4]+d0d3d4=15000+0+10×5×80=19000m[1, 3] + m[4, 4] + d_0 d_3 d_4 = 15000 + 0 + 10 \times 5 \times 80 = 19000

Thus, the minimum number of scalar multiplications is 19000, achieved by the parenthesization ((M1×(M2×M3))×M4)((M_1 \times (M_2 \times M_3)) \times M_4).

Hence, the correct option is (C).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Algorithm Design Techniques previous year question is Q38 of the GATE CSE 2011 paper. Find more GATE CSE PYQs on Algorithm Design Techniques in Algorithms, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Algorithm Design Techniques PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Algorithm Design Techniques in GATE CSE

Algorithm Design Techniques has 6 GATE CSE PYQs across 6 papers from 2011 to 2017. This is the only 2-mark MCQ among them, and it is the only one in GATE CSE 2011.

How GATE tests Algorithm Design Techniques

More from GATE CSE 2011

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2011 · Q38 · MCQ

Four matrices M1, M2, M3 and M4 of dimensions p × q, q × r, r × s and s × t respectively can be multiplied in several ways with different number of total scalar multiplications. For example when multiplied as ((M1 × M2) × (M3 × M4)), the total number of scalar multiplications is pqr + rst + prt. When multiplied as (((M1 × M2) × M3) × M4), the total number of scalar multiplications is pqr + prs + pst. If p = 10, q = 100, r = 20, s = 5, and t = 80, then the minimum number of scalar multiplications needed is

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.