Homework 1 Solutions
Fundamental Algorithms, Spring 2008, Professor Yap
Due: Wed Feb 6, in class.
HOMEWORK with SOLUTION, prepared by Instructor and T.A.s
INSTRUCTIONS:
•
Please read questions carefully. When in doubt, please ask. You may also post general questions to
the homework discussion forum in class website. Also, bring your questions to recitation on Monday.
•
There are links from the homework page to the old homeworks from previous classes, including solu
tions. Feel free to study these.
1. (10 Points)
Exercise 7.1 in Lecture 1. Assume
f
(
n
)
≥
1 (ev.).
(a) Show that
f
(
n
) =
n
O
(1)
i± there exists
k >
0 such that
f
(
n
) =
O
(
n
k
). This is mainly an exercise
in unraveling our notations!
(b) Show a counter example to (a) in case
f
(
n
)
≥
1 (ev.) is false.
SOLUTION:
a) Let
f
(
n
)
≥
1 (ev) and assume that
f
(
n
) =
n
O
(1)
. Therefore there
exists a
g
∈ O
(1) such that
g
(
n
)
≤
k
(ev) and
f
(
n
)
≤
n
g
(
n
)
≤
n
k
(ev). This shows
that
f
(
n
)
∈ O
(
n
k
). In the other direction, suppose
f
=
O
(
n
k
). Then
f
≤
Cn
k
(ev) for
some
C >
1. Thus
f
≤
n
k
+
ǫ
(ev) for any
ǫ >
0 (we This shows
f
=
n
O
(1)
.
b) To ²nd a counterexample, let
f
(
n
) = 1
/
2. Clearly
f
=
O
(
n
). But
f
(
n
)
n
=
n
O
(1)
because if
f
(
n
) =
n
g
(
n
)
for some function
g
(
n
), then clearly
g
(
n
)
<
0 (ev). But this
means
g
(
n
)
n
=
O
(1). Recall that
g
∈ O
(1) implies
g
≥
0 (ev).
2. (25 Points)
Do Exercise 7.5, Lecture 1 (in 8 parts). Provide either a counterexample when false or a proof when
true. The base
b
of logarithms is arbitrary but ²xed, and
b >
1. Assume the functions
f, g
are arbitrary
(do not assume that
f
and
g
are
≥
0 eventually).
(a)
f
=
O
(
g
) implies
g
=
O
(
f
).
(b) max
{
f, g
}
= Θ(
f
+
g
).
(c) If
g >
1 and
f
=
O
(
g
) then ln
f
=
O
(ln
g
). HINT: careful!
(d)
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '10
 .
 Algorithms, LG, Catalan number, Threaded binary tree

Click to edit the document details