Why does memoizing the recursion for the matrix chain multiplication not work (for efficiency purposes)? (see below)
memo={}
def minMultiplications(dims):
if (len(dims)<=2):
# write your code here
return 0
elif tuple(dims) in memo:
return memo[tuple(dims)]
else:
cand=[]
for i in range(3,len(dims)+1,1):
dim1= dims[:i-2] + dims[i-1:]
cand.append( dims[i-3] * dims[i-2]*dims[i-1] + minMultiplications(dim1) )
memo[tuple(dims)]=min(cand)
return min(cand)
stressTesting = True