Problem 55315. Chain multiplication - 04
However, here in this problem, you will be given a chain of matrices as a string with parenthesis placed in certain places along with their dimensions. You have to find out the number of multiplications required if you multiply the matrices that way.
For example,
d= [1, 2, 3, 2] and s = "A(BC)".
here, the sizes of the matrices are - A(1,2), B(2,3), and C(3,2).
First, B and C are to be multiplied (since they are inside parenthesis). The resultant matrix is to be multiplied with A. You need to find out the total number of multiplications required, which is 12+4=16.
n.b. only valid parenthesization are given in this problem for simplicity.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers4
Suggested Problems
-
Find the sum of all the numbers of the input vector
49676 Solvers
-
Find state names that start with the letter N
1267 Solvers
-
How to find the position of an element in a vector without using the find function
2742 Solvers
-
Similar Triangles - find the height of the tree
444 Solvers
-
Removing rows from a matrix is easy - but what about inserting rows?
222 Solvers
More from this Author165
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!