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. Don’t 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 say“n1/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,nn√logn.List 2, slow growing functions: 2log*n,log*(22n),2√logn,log log√n,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 allx≥2, 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!< nn√logn.•List 2: log*(22n)<2log*n<log log√n <log(n5)<2√logn2Recurrences[10 points] Solve the following recurrences, giving your answer inThetanotation. For each of them,assume the base caseT(x) = 1 forx≤5. 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 is∑log4ni=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 untiln≤5, and at everylevelndecreases by the square root. So at leveli, the value ofnisn1/2i. So we just solveforiby settingn1/2i≤5, implying that12ilogn≤log 5, and hence that 2i≥logn/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
- Spring '09
- Algorithms, Greedy algorithm, Big O notation, Matroid