Question: Question 4 (10 marks) The recursive algorithm Fib, shown in Figure 1. takes as input an integer n20 and returns the - th Fibonacci numbers
Question 4 (10 marks) The recursive algorithm Fib, shown in Figure 1. takes as input an integer n20 and returns the - th Fibonacci numbers Algorithm Fi(n): if noor n=1 then else - Fra(n-1) + Fun-2) endir return Figure 1: Fibonacci Algorithm 1 Let or be the number of additions made by algorithm Fi(n), ie, the total number of time the +-function in the else-case is called. Prove that for all 20. 0.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? Question 5 [10 marks) Letn 2 be an integer and considera quence of n pairwise distinct mambers. The following algorithm, shown in Figure 2, computes the smallest and largest elements in this sequences Algorithm Mix Max(.....): (1) min 8 TOT for 2 ton do if
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
