by spoonman1 · 11y ago · 0 comments
The author is saying that the naive recursive algorithm is incredibly slow. That would be an implementation like this (in Python):
def fib(n):
if n < 2:
return n
else:
return fib(n-1) + fib(n-2)
And that implementation is slow. It's exponentially slow.As a side note, the Java and C# implementations of the "fast doubling" algorithm actually used a fixed number of loop iterations instead of the mathematical recursive formula.
To use Ableson's precise language:
Every iterative procedure can be expressed as
a recursive *definition.*
SICP is written to carefully avoid overloading terms: "Function" is reserved for mathematical functions and "closure" is reserved for algebraic closure.The fast doubling algorithm has a recursive definition and produces a logarithmic procedure.
The classic implementation based on the mathematical definition:
def F(n):
if n == 0: return 0
elif n == 1: return 1
else: return F(n-1)+F(n-2)
Has a recursive definition and produces a recursive procedure [even worse the recursive procedure runs in exponential time]. It is also possible to create a recursive definition of a procedure that runs in linear time.[node 15]: https://mitpress.mit.edu/sicp/full-text/sicp/book/node15.htm...
[1] http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html...