This week in lecture time we learned about Algorithm efficiency. What specifically caught my eye was memoization. Memoization is a technique that is used to speed up program efficiency by eliminating redundant function calls. This technique still allows the function to produce its expected output each time. For example, Let's say you have a recursive function called f(int_num) that constantly produced the call f(30). Let's also say that f(30) always evaluated to the same integer every time it was solved by the function. So then, why bother letting the program waste time to evaluate f(30) when you can just store the value of f(30) (in a dictionary for example) and replace any f(30) calls seen in the future with its value? This technique would save a lot of processing power.
No comments:
Post a Comment