Monday, May 15, 2006

Fibonacci numbers

I came across three algorithms to compute the nth Fibonacci number. The last one is beautiful :)

(1) Recursive algorithm (exponential time)
(2) Non-recursive algorithm (linear time)
(3) Algorithm based on the usage of matrices (logarithmic time)

For details, refer http://en.wikipedia.org/wiki/Fibonacci_number

No comments: