Unformatted text preview: Return fib1(n-1) + fib1(n-2); Iterative algorithm: fib2(n) If n = = 0 or 1 Return 1 Else prev = temp =1; For I = 2 through n do prev2prev = prev; prev=temp; temp = prev+prev2prev; Return temp; Implement these two algorithms. Run them with increasing input n and find out what happens with the run times. Optionally you may like to measure the run time of each of the programs and plot them against increasing n. Submission: source codes and a few lines of description regarding the run times. Graduate class: 4. Prove that if f(n) = Θ (g(n)), then g(n) = Θ (f(n))....
View Full Document
- Spring '12
- Algorithms, Euclidean algorithm, Fibonacci number, Golden ratio