Question: Question 4 (10 marks] The recursive algorithm Fib, shown in Figure 1, takes as input an integer n > 0 and returns the n- th

 Question 4 (10 marks] The recursive algorithm Fib, shown in Figure

Question 4 (10 marks] The recursive algorithm Fib, shown in Figure 1, takes as input an integer n > 0 and returns the n- th Fibonacci number fn. Algorithm FIB(n): if n = 0 or n=1 then f = n else f = FIB(n 1) + FIB(n 2) endif; return f Figure 1: Fibonacci Algorithm. 1 Let ar 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, ans = 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!