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 fn fn where the running times of these correspond to Theta n and Theta n respectively. def fx s:; n len x s; ; ix sn; if i :; return fn; return fn; n In the above function, i denotes the remainder after dividing n by It is when i is even and 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 OOmega or Theta as appropriate Explain your answer. d Analogously, give the best possible lower bound on the asymptotic running time for arbitrary ne Suppose, instead, that all you know is that the running time of fn is in Omega n while the running time of fn remains Theta n 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
