Write code for Fibonacci algorithm (iterative or recursive) and explain what's the performance.
Utilisateur anonyme
When using recursive method, one way to improve performance is to store the computed values in a global array. ex: To calculate Fib(5), we calculate Fib(4) + Fib(3) Now Fib(4) again calculates Fib(3) & Fib(2) which is repeating the calculations For large values of n, this leads to too many recursive calls. So, as and when we calculate Fib(k) we can store the value in a global array and reuse it to improve performance.