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

Function print_optimal_solution

dynamic_programming/matrix_chain_order.py:37–48  ·  view source on GitHub ↗

Print order of matrix with Ai as Matrix.

(optimal_solution: list[list[int]], i: int, j: int)

Source from the content-addressed store, hash-verified

35
36
37def print_optimal_solution(optimal_solution: list[list[int]], i: int, j: int):
38 """
39 Print order of matrix with Ai as Matrix.
40 """
41
42 if i == j:
43 print("A" + str(i), end=" ")
44 else:
45 print("(", end=" ")
46 print_optimal_solution(optimal_solution, i, optimal_solution[i][j])
47 print_optimal_solution(optimal_solution, optimal_solution[i][j] + 1, j)
48 print(")", end=" ")
49
50
51def main():

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected