Matrix | dimension |
A1 | 10*20 |
A2 | 20*50 |
A3 | 50*1 |
A4 | 1*100 |
we want to compute A1*A2*A3*A4
Matrix Ai has Pi-1 rows, Pi columns.
Input p
10 | 20 | 50 | 1 | 100 |
first think about computing cost of optimal solution recursively.
Consider the (sub)problem Ai*Ai+1*...*Aj