Answer: C
To find the optimal parenthesization of the matrix chain F1F2F3F4F5, we use dynamic programming. The dimensions of the matrices are:
- F1:2×25
- F2:25×3
- F3:3×16
- F4:16×1
- F5:1×1000
Let m[i,j] denote the minimum number of scalar multiplications needed to compute the product Fi…Fj. We compute the values for chains of increasing length:
- Length 2:
m[1,2]=2×25×3=150
m[2,3]=25×3×16=1200
m[3,4]=3×16×1=48
m[4,5]=16×1×1000=16000 - Length 3:
m[1,3]=min(m[1,2]+2×3×16,m[2,3]+2×25×16)=min(150+96,1200+800)=246 →(F1F2)F3
m[2,4]=min(m[2,3]+25×16×1,m[3,4]+25×3×1)=min(1200+400,48+75)=123 →F2(F3F4)
m[3,5]=min(m[3,4]+3×1×1000,m[4,5]+3×16×1000)=min(48+3000,16000+48000)=3048 →(F3F4)F5 - Length 4:
m[1,4]=min(m[2,4]+2×25×1,m[1,2]+m[3,4]+2×3×1,m[1,3]+2×16×1)=min(123+50,150+48+6,246+32)=173 →F1(F2(F3F4))
m[2,5]=min(m[2,4]+25×1×1000,…)=123+25000=25123 →(F2(F3F4))F5 - Length 5:
m[1,5]=min(m[1,4]+2×1×1000,…)=173+2000=2173 →((F1(F2(F3F4)))F5)
The optimal parenthesization is (((F1(F2(F3F4)))F5). In this structure, the only pair of adjacent matrices from the original chain that is directly multiplied is F3F4. Thus, the only explicitly computed pair is F3F4.