The versions of Fibonacci compute the same result. Which ones run faster?
The order of a computation, written O(f(n)) (sometimes called ``big O'' notation) describes the time required to perform the computation for a problem of size n, as n becomes large.
The iterative (fibonacci n) and recursive (fibon n) are O(n), that is, the time they require is linear in the size of the input. We assume that the operation + takes constant time, which is not strictly true in this case.
What is the order of the recursive function (fib n)?
Contents    Page-10    Prev    Next    Page+10    Index