Thursday, November 28, 2013

Memoization

Memoization

Lastly, we discussed redundancy in recursive programming. With the example of Fibonacci's function, we covered how the number of redundant recursive calls can greatly slow down the Python interpreter, resulting in the output to be returned after an extremely long time. Avoiding redundancy in recursive programming was another new concept to me. I never thought about setting up the recursive code so that there is no need to recursively perform redundant calls. The use of a dictionary and how adding all recursive calls and their results to that dictionary (if the call is already in the dictionary, then there is no need to perform the call) can greatly improve the efficiency of code, both performance-wise and time-wise.

No comments:

Post a Comment