Question: The recursive algorithm Fib, shown in Figure 1, takes as input an integer n > 0 and returns the n - th Fibonacci number fr.


The recursive algorithm Fib, shown in Figure 1, takes as input an integer n > 0 and returns the n - th Fibonacci number fr. Algorithm FiB(n): if n = O or n=1 then f=n else f = FIB(n 1) + FIB(n 2) endif; return f Figure 1: Fibonacci Algorithm. Let an be the number of additions made by algorithm Fib(n), i.e., the total number of times the +-function in the else-case is called. Prove that for all n > 0. an = fn+1 -1. The algorithm is not efficient in terms of the total number of operations carried out. Without you having to give the actual such number, can you pin-point exactly where the inefficiency results from
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
