Question: Please help me . . Consider the algorithm f which takes a positive integer and in turn calls functions f _ 0 ( n )

Please help me .. Consider the algorithm f which takes a positive integer and in turn calls functions f_0(n), f_1(n) where the running times of these correspond to \Theta (n) and \Theta (n^2), respectively. [1 def f(x s):; 2 n= len (x s); 3 ; 4 i=x s[n-1]; 5 if i %2=0:; 6 return f_-0(n); 7 return f_-1(n); 8(n)] In the above function, i %2 denotes the remainder after dividing n by 2. It is 0 when i is even and 1 when i is odd. (a) What is the best case asymptotic running time for the above function? Note that since I am asking for best case, you may assume n is restricted to the class of input that makes the above algorithm run the fastest. For this class of input the algorithm runs in time \Theta (something). Explain your answer. (b) Analogously, what is the worst case asymptotic running time? (c) Give the best possible upper bound on the asymptotic running time for arbitrary n. This should be denoted with O,\Omega , or \Theta (as appropriate). Explain your answer. (d) Analogously, give the best possible lower bound on the asymptotic running time for arbitrary n.(e) Suppose, instead, that all you know is that the running time of f_0(n) is in \Omega (n), while the running time of f_1(n) remains \Theta (n^2). What are the best lower and upper bounds that you can give on the asymptotic running time for best case, worst case, and general 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 Programming Questions!