This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 15-750HW 0 Solutions115-750 Graduate Algorithms Spring 2009Miller and Dinitz and TangwongsanAssignment 0 Solutions1Asymptotic Notation[10 points] For each list of functions, order them according to increasing asymptotic growth. Pro-vide a brief argument justifying each successive step in the ordering. Your answers should looksomething like:n1/2< n= 5n < n2. Dont forget to mention iff(n) = (g(n)).Disclaimer:itisnotstandard notation to writen1/2< n= 5n < n2under big-O notation. Nor is it standardto write (n1/2) =o(n) = (5n) =o(n2). When writing a paper, it would be better to sayn1/2=o(n) andn= (5n) and 5n=o(n2), but this would be longer for you to write and for usto grade.List 1, fast growing functions: 23n,32n,n!,nlog*n,nnlogn.List 2, slow growing functions: 2log*n,log*(22n),2logn,log logn,log(n5)Recall that log*(n) (the log star function) calculates how many times you would need to take theiterated log2ofnbefore you would go below 2. Formally, log*(x) = 0 for allx(0,2), and for allx2, log*(x) = 1 + log*(log2(x)). Thus for example log*(2) = 1,log*(22) = 2, and log*(2(22)) = 3.Solution:List 1:nlog*n<23n<32n< n!< nnlogn.List 2: log*(22n)<2log*n<log logn <log(n5)<2logn2Recurrences[10 points] Solve the following recurrences, giving your answer inThetanotation. For each of them,assume the base caseT(x) = 1 forx5. Show your work.a)T(n) = 3T(n/4) +nb)T(n) =T(n-2) +n4c)T(n) = 2T(n-5)d)T(n) =nT(n) +nSolution:a)T(n) = (n). In the recursion tree, the amount of work done at leveliis (34)in, and thereare log4nlevels. Thus the total work islog4ni=0(34)in= (n).15-750HW 0 Solutions2b)T(n) = (n5). Expanding this out, there are at mostn/2 terms, each of which is at mostn4,soT(n) =O(n5). There are also at leastn/4 terms that are at least (n/2)4, soT(n) = (n5).ThusT(n) = (n5).c)T(n) = (2n/5). At each expansion the value double, and there are clearly betweenn/5-1andn/5 + 1 expansions.d)T(n) = (nlog logn). It is easy to see that each level of the recursion tree doesnwork. Tofigure out the number of levels, note that the recursion will last untiln5, and at everylevelndecreases by the square root. So at leveli, the value ofnisn1/2i. So we just solveforiby settingn1/2i5, implying that12ilognlog 5, and hence that 2ilogn/log 5.Taking logs one more time, we get thati(log logn). Thus there are (log logn) levels,soT(n) = (nlog logn).3Probability[10 points] Suppose that we flip a fair coin until we see two heads in a row. This can be modeledby taking a random walk on the following graph, in which we start in the leftmost state and endwhen we reach the rightmost state.HTHTa)Draw the graph corresponding to flipping the coin until we see the sequence Heads, Tails,Heads....
View Full Document
This document was uploaded on 11/03/2009.
- Spring '09