Matrix chain multiplication

Can you provide proper code where we can input data and then implement this function, and what is A in this code and why we have taken n as A.size()-1

hello @shubhangis248 please see this code :


if you dont understand anythin you can ask here .
Happy Learning !!

when we are given input arr[],so what we are actually taking in input arr[],the cost or something else?

hey @shubhangis248 no these are the dimensions of the matrices.

dimensions of the matrices should be in 2-d then how these are store in 1-d?

take this example :
Input: p[] = {40, 20, 30, 10, 30}
Output: 26000.
There are 4 matrices of dimensions 40x20, 20x30, 30x10 and 10x30. Let the input 4 matrices be A, B, C and D. The minimum number of multiplications are obtained by putting parenthesis in following way (A(BC))D --> 203010 + 402010 + 401030

run the code given by me for this test case and the output will be the same .

okay,I understood what you are saying.

hey @shubhangis248 you can now mark this doubt as resolved . please give the star rating .
Happy Learning !!