时空权衡——斐波那契数列(Time/Space Tradeoff - Fibonacci Sequence)
斐波那契数列简介(Introduction)
In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, called Fibonacci sequence, characterised by the fact that every number after first two is the sum of the two preceding ones:
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233…
The problem is finding the nth Fibonacci number.
算法(Algorithm)
We can use “time and space tradeoff” design algorithm technique, which is decreasing the time required to solve a problem by using additional memory in a clever way.
We use a table to tabulate the function FIB as we go: Once an intermediate result has been computed, it not only return the result to caller but also store it in the table. So each call to FIB first check if the needed value is there, if it is not, the usual recursive pro