Three Algorithms for Fibonacci

1. exponential algorithm: fib1(n) = fib1 (n-1) + fib1(n-2). running time: O(1.6n)

2. polynomial algorithm: which is also linear programming, running time  O(n2)

3. using matrix multiplication:  assume m bits multiplication time is M(n). T(n) = T (n/2) + M(n).

Note: the sum of geometric series is simply the largest term, so T(n) = O(M(n)).

So to compare algorithm 2 and 3, it is necessary to know whether the multiplication time is bigger than O(n2).

But the fact is multiplication time is O(n2), so algorithm 2 and 3 are equivalent.

你可能感兴趣的:(algorithms)