This preview shows pages 1–3. Sign up to view the full content.
CS161: Design and Analysis of Algorithms
Summer 2004
Problem Set #1 Solutions
General Notes
•
Regrade Policy:
If you believe an error has been made in the grading of your problem
set, you may resubmit it for a regrade. If the error consists of more than an error in
addition of points, please include with your problem set a detailed explanation of
which problems you think you deserve more points on and why. We reserve the right
to regrade your entire problem set, so your Fnal grade may either increase or decrease.
•
If you use pseudocode in your assignment, please either actually use psuedocode or
include a written explanation of your code. The TA does not want to parse through
C or JAVA code with no comments.
•
If you fax in your problem set, please make sure you write clearly and darkly. Some
problem sets were very di±cult to read. Also, make sure that you leave enough margins
so that none of your work is cut o².
•
The version of the Master Theorem that was given in lecture is slightly di²erent from
that in the book. We gave case 2 as
f
(
n
) = Θ(
n
log
b
a
log
k
n
) =
⇒
T
(
n
) = Θ(
n
log
b
a
log
k
+1
n
) for
k
≥
0
On exams, using the Master Theorem is normally quicker than other methods. But,
remember that cases 1 and 3 only apply when
f
(
n
) is polynomially smaller or larger,
which is di²erent from asymptotically smaller or larger.
1.
[16 points] Ordering By Asymptotic Growth Rates
Throughout this problem, you do not need to give any formal proofs of why one function
is Ω, Θ, etc.
.. of another function, but please explain any nontrivial conclusions.
(a)
[10 points]
Do problem 33(a) on page 58 of CLRS.
Rank the following functions by order of growth; that is, Fnd an arrangement
g
1
, g
2
, . . . , g
30
of the functions satisfying
g
1
= Ω(
g
2
)
, g
2
= Ω(
g
3
)
, . . . , g
29
= Ω(
g
30
).
Partition your list into equivalence classes such that
f
(
n
) and
g
(
n
) are in the
same class if and only if
f
(
n
) = Θ(
g
(
n
)).
lg(lg
*
n
)
2
lg
*
n
(
√
2)
lg
n
n
2
n
!
(lg
n
)!
(
3
2
)
n
n
3
lg
2
n
lg(
n
!)
2
2
n
n
1
/
lg
n
lnln
n
lg
*
n
n
·
2
n
n
lg lg
n
ln
n
1
2
lg
n
(lg
n
)
lg
n
e
n
4
lg
n
(
n
+ 1)!
√
lg
n
lg
*
(lg
n
)
2
√
2 lg
n
n
2
n
n
lg
n
2
2
n
+1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document Problem Set #1 Solutions
2
Answer:
Most of the ranking is fairly straightforward. Several identities are
helpful:
n
lg lg
n
= (lg
n
)
lg
n
n
2
= 4
lg
n
n
= 2
lg
n
2
√
2 lg
n
=
n
√
2
/
lg
n
1 =
n
1
/
lg
n
lg
*
(lg
n
) = lg
*
n

1 for
n >
1
In addition, asymptotic bounds for Stirling’s formula are helpful in ranking the
expressions with factorials:
n
! = Θ(
n
n
+1
/
2
e

n
)
lg(
n
!) = Θ(
n
lg
n
)
(lg
n
)! = Θ((lg
n
)
lg
n
+1
/
2
e

lg
n
)
Each term gives a diFerent equivalence class, where the
>
symbol means
ω
.
This is the end of the preview. Sign up
to
access the rest of the document.
This document was uploaded on 05/25/2011.
 Summer '09
 Algorithms

Click to edit the document details