to calculate the min step of multiplicate some matixs package dynamic_programming; public class matrix_chain_order { //input is a sequence p = p0,p1..pn,where p.length = n+1 (matrix n is pn-1pn) int[] p; int[][] cost; public matrix_chain_order(int[]…