Big-O for various Fibonacci Implementations
问题 I just tried implementing code (in Java) for various means by which the nth term of the Fibonacci sequence can be computed and I'm hoping to verify what I've learnt. The iterative implementation is as follows: public int iterativeFibonacci(int n) { if ( n == 1 ) return 0; else if ( n == 2 ) return 1; int i = 0, j = 1, sum = 0; for ( ; (n-2) != 0; --n ) { sum = i + j; i = j; j = sum; } return sum; } The recursive implementation is as follows :- public int recursiveFibonacci(int n) { if ( n ==