Casting recursion dynamically
The basis of dynamic programming is to achieve something as effective as brute-
force searching without actually spending all the time doing the computations
required by a brute-force approach. You achieve the result by trading time for disk
space or memory, which is usually done by creating a data structure (a hash table,
an array, or a data matrix) to store previous results. Using lookup tables allows
you to access results without having to perform a calculation a second time.
The technique of storing previous function results and using them instead of the
function is memoization, a term you shouldn’t confuse with memorization.
Memoization derives from memorandum, the Latin word for “to be remembered.”
CHAPTER 16
Do'stlaringiz bilan baham: |