Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Give the asymptotic running time of each of the following functions in notation. Justify your answer (write all details). What is the asymptotic worst case
Give the asymptotic running time of each of the following functions in notation. Justify your answer (write all details). What is the asymptotic worst case running time? Whats the asymptotic expected running time? Random(n): generates a random number between 1 and n with uniform distribution. CoinFlip(): returns heads or tails with equal probability.
YOUR STEPS SHOULD LOOK LIKE THIS:
Steps 2-4 take c time. (a) In the worst case c1=c2 so statement 6 is executed. T(n)=c+T(n4)+T(n7)T(n4)+T(n7)2T(n7)22T(n14)222T(n21)n/72222T(1)2n/7c(2n/7). Since T(n)(2n/7), worst case running time T(n) has an exponential lower bound. (b) Prob(c1=c2) is 1/2. ET(n)ET(n)ET(n)=Prob(c1=c2)ET(c1=c2)+Prob(c1=c2)ET(c1=c2)=(1/2)(c+T(n4)+T(n7))+(1/2)c=c+(1/2)T(n4)+(1/2)T(n7).=c+(1/2)T(n4)+(1/2)T(n7)c+(1/2)T(n4)+(1/2)T(n4)=c+T(n4)=c+c+T(n8)=n/4c+c++T(1)=n/4c+c++c=cn/4=c+(1/2)T(n4)+n/7(1/2)T(n7)c+(1/2)T(n7)+n/7(1/2)T(n7)=c+T(n7)=c+c+T(n14)=c+c++T(1)=c+c++c=cn/7 Since cn/7ET(n)cn/4, expected running time ET(n)(n)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started