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

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 max then mat endir endwhile; return (min, mar) (2) Figure 2: Min Max Algorithm This algorithm takes comparison between input elements in lines (1) and (2). Determine the total number of comparisons in a function of n

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!