Memoization

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

Memoization (or memoisation) is a technique from computer programming to optimize a computer program. Computer programs call functions. Each function calculates a result it will return. Memoization is simple: before the value is returned from the function call, it is stored in a table (or associative array). Like a cache, this array will only be able to store a limited number f results. The function can then be changed so it tries to look up the value of the input in its lookup table. This lookup is much less expensive than doing the calculation again. Also like a cache: the data table will be cleaned periodically, for examples the values that have not been lookued up for a given time are removed.

Although related to caching, memoization refers to a specific case of this optimization, distinguishing it from forms of caching such as buffering or page replacement. In the context of some logic programming languages, memoization is also known as tabling; see also lookup table.