"Introduction to Algorithms" chain matrix multiplication in Java

"Introduction to Algorithms" chain matrix multiplication in Java
There were problems A1A2 ... An n matrices, the size of the i-th matrix is ​​pi-1 * pi, the computational cost is determined by the scalar multiplication, and the minimum cost sequence of operations. For example: the corresponding answer is: 15125 multiplications ideas provided m [i, j] represents the minimum calculation of the cost matrix chain from i to j, s [i, j] = k represents behind the increase in matrix K i and j intermediate a bracket, the method is recursive m: the first is the first half, a second half of the second, the third is the computational cost of the two-part composition before and after. Final m [1, n] is the minimum cost. Because it is ijk triple traverse, so complexity is Θ (n3). While recursive, to record the smallest k. How that s [i, j] to obtain the final calculation cis ...

Continue reading : Code farm >> "Introduction to Algorithms" chain matrix multiplication in Java

Original link : http://www.hankcs.com/program/algorithm/algorithm-introduction-matrix-chain-multiplication-java-implementation.html

Reproduced in: https: //my.oschina.net/hankcs/blog/618194

Guess you like

Origin blog.csdn.net/weixin_33981932/article/details/91780362