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

func 9(A,n)/A= array of n integers */ if (n10) then return A[1]; end s0 for i1 to n1 do B[i]A[i]+A[i+1] ss+A[i]; end kRandom(n/5]) ss+func9(A,k); ss+func9(A,nk) return (s); 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

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions

Question

1. Describe the types of power that effective leaders employ

Answered: 1 week ago