Answered step by step
Verified Expert Solution
Link Copied!

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.

image text in transcribed

YOUR STEPS SHOULD LOOK LIKE THIS:

image text in transcribed

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

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

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions

Question

Find the exact solution of equation. 3 cos -1 (2x) = 2

Answered: 1 week ago