Question 3) Looking carefully at the Fibonacci definition shows that calculating Fibonacci number fn-1 requires calculating Fibonacci number fn-2, which is also required for calculating Fibonacci number fn. This means there is redundant computation. This redundancy gets worse for numbers fn-3, fn-4, etc.
Fortunately, the Fibonacci sequence is relatively easy to compute non-recursively. That is your problem here. The trick is to build up the solution using a for loop that calculates f2, then f3, then f4, etc. Implement your solution in prob3.py.
1. The following code recursively calculates the maximum value in a list.
Jef recursive max_impl(L, 1):
The actual recursive function.
== len(L)-l: return L[i] else: return Max(Llil, recursive max_impl(l,i+l
Jef recursive max(L):
The driver for the recursive function. This case empty list and otherwise makes the recursive function
if len(L) return ~99999 By convention else: return recursive_Max impl(
name ~_Main [5 print(recursive max(Li)) 24, 23.1, 12, 15, 1] print(recursive_max(L2)) L2.append(print(recursive_max(L2))
Using this as a guide, write recursive function to add the values in a list. You should have to change very little code: Implement your code in the provided file probl.Py 2. Implement recursive solution to the Fibonacci number function definition given during lecture: Implement your code in the provided file prob2.Py 3. Looking carefully at the Fibonacci definition shows that calculating Fibonacci number fn-1 requires calculating Fibonacci number fn-2, which is also required for calculating Fibonacci number fn. This means there is redundant computation. This redundancy gets worse for numbers fn-3, fn-4 etc.
Fortunately, the Fibonacci sequence is relatively easy to compute non-recursively.