Matrix chain multiplication: Difference between revisions
Content added Content deleted
m (→{{header|zkl}}: added test case) |
|||
Line 555:
=== Iterative solution ===
In the previous solution, memoization is done blindly with a dictionary. However, we need to compute the optimal products for all sublists. A sublist is described by its first index and length (resp. i and j+1 in the following function), hence the set of all sublists can be descibed by the indices of elements in a triangular array u. We first fill the "solution" (there is
<lang python>def optim4(a):
|