Memory-bound function – link to Fibonacci

It is not possible to add the new link because it would replace an existing, longer link.

Line 2: Line 2:
Memory-bound [[subroutine|functions]] and memory functions are related in that both involve extensive memory access, but a distinction exists between the two.
Memory-bound [[subroutine|functions]] and memory functions are related in that both involve extensive memory access, but a distinction exists between the two.


Memory functions use a [[dynamic programming]] technique called [[memoization]] in order to relieve the inefficiency of [[recursion]] that might occur. It is based on the simple idea of calculating and storing solutions to subproblems so that the solutions can be reused later without recalculating the [[optimal substructure|subproblems]] again. The best known example that takes advantage of memoization is an [[algorithm]] that computes the [[Fibonacci number]]s. The following [[pseudocode]] uses recursion and memoization, and runs in [[linear time|linear CPU time]]:
Memory functions use a [[dynamic programming]] technique called [[memoization]] in order to relieve the inefficiency of [[recursion]] that might occur. It is based on the simple idea of calculating and storing solutions to subproblems so that the solutions can be reused later without recalculating the [[optimal substructure|subproblems]] again. The best known example that takes advantage of memoization is an [[algorithm]] that computes the [[Fibonacci]] numbers. The following [[pseudocode]] uses recursion and memoization, and runs in [[linear time|linear CPU time]]:
<syntaxhighlight lang="c">
<syntaxhighlight lang="c">
Fibonacci (n)
Fibonacci (n)