(Solved) : 6 Consider Fibonacci Numbers F N F N 1 F N 2 N 1 F 0 0 F 1 1 Write Recursive Function Com Q43914202 . . .

6. Consider the Fibonacci numbers: F(n) = F(n − 1) + F(n − 2), n > 1; F(0) = 0; F(1) = 1. a). Write a recursive function to compute F(n) using the above definition directly. Imple- ment your solution and print F(i*5), where 0 si < 10, as output. b). Write a recursive function/procedure to compute F(n) with time complexity O(n) (more precisely, the time complexity should be O(nA(n)) when n is large, where A(n) is the com- plexity of adding F(n-1) and F(n–2)). Implement your solution and print F(i*10), where 0 < i < 30, as output. This program must be able to compute F(n) precisely for n < 300. (Hint 1: design a recursive algorithm that returns both F(n) and F(n − 1) with input n.) (Hint 2: can you use a primitive type to store F(300)?) Show transcribed image text 6. Consider the Fibonacci numbers: F(n) = F(n − 1) + F(n − 2), n > 1; F(0) = 0; F(1) = 1. a). Write a recursive function to compute F(n) using the above definition directly. Imple- ment your solution and print F(i*5), where 0 si
Expert Answer
Answer to 6. Consider the Fibonacci numbers: F(n) = F(n − 1) + F(n − 2), n > 1; F(0) = 0; F(1) = 1. a). Write a recursive func…
OR