MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / main

Function main

dynamic_programming/matrix_chain_order.py:51–63  ·  view source on GitHub ↗

Size of matrix created from array [30, 35, 15, 5, 10, 20, 25] will be: 30*35 35*15 15*5 5*10 10*20 20*25

()

Source from the content-addressed store, hash-verified

49
50
51def main():
52 """
53 Size of matrix created from array [30, 35, 15, 5, 10, 20, 25] will be:
54 30*35 35*15 15*5 5*10 10*20 20*25
55 """
56
57 array = [30, 35, 15, 5, 10, 20, 25]
58 n = len(array)
59
60 matrix, optimal_solution = matrix_chain_order(array)
61
62 print("No. of Operation required: " + str(matrix[1][n - 1]))
63 print_optimal_solution(optimal_solution, 1, n - 1)
64
65
66if __name__ == "__main__":

Callers 1

Calls 2

print_optimal_solutionFunction · 0.85
matrix_chain_orderFunction · 0.70

Tested by

no test coverage detected