Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 4 (10 marks) The recursive algorithm Fib, shown in Figure 1. takes as input an integer n20 and returns the - th Fibonacci numbers

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago