Question: d) Consider the following function: def F(n): if n == 0: return 0 elif n == 1: return 1 else: return F(n-1) + F(n-2)
d) Consider the following function: def F(n): if n == 0: return 0 elif n == 1: return 1 else: return F(n-1) + F(n-2) 1) Derive the complexity of this function (2 marks) 2) Explain how you can modify this function in order to minimize its complexity to be linear. [Hint: use simple instruction] (3 marks)
Step by Step Solution
3.40 Rating (150 Votes )
There are 3 Steps involved in it
1The given function is recursive implementation of the Fibonacci Sequence and ... View full answer
Get step-by-step solutions from verified subject matter experts
