Massachusetts Institute of Technology
6.042J/18.062J, Spring ’10
: Mathematics for Computer Science
April 7
Prof. Albert R. Meyer
revised April 7, 2010, 888 minutes
Solutions
to
InClass
Problems
Week
9,
Wed.
Problem
1.
Recall that for functions
f, g
on
N
,
f
=
O
(
g
)
iff
∃
c
∈
N
∃
n
0
∈
N
∀
n
≥
n
0
c
·
g
(
n
)
≥ 
f
(
n
)

.
(1)
For each pair of functions below, determine whether
f
=
O
(
g
)
and whether
g
=
O
(
f
)
. In cases
where one function is O() of the other, indicate the
smallest
nonegative
integer
,
c
, and for that small
est
c
, the
smallest
corresponding
nonegative
integer
n
0
ensuring that condition (
1
) applies.
(a)
f
(
n
) =
n
2
, g
(
n
) = 3
n
.
f
=
O
(
g
)
YES
NO
If YES,
c
=
,
n
0
=
Solution.
NO.
�
g
=
O
(
f
)
YES
NO
If YES,
c
=
,
n
0
=
Solution.
YES, with
c
= 1
,
n
0
= 3
, which works because
3
2
= 9
,
3
3 = 9
.
�
·
(b)
f
(
n
)
=
(3
n
−
7)
/
(
n
+
4)
, g
(
n
) = 4
f
=
O
(
g
)
YES
NO
If YES,
c
=
,
n
0
=
Solution.
YES, with
c
= 1
, n
0
= 0
(because

f
(
n
)

<
3
).
�
g
=
O
(
f
)
YES
NO
If YES,
c
=
,
n
0
=
Solution.
YES, with
c
= 2
, n
0
=
15
.
Since
lim
n
→∞
f
(
n
) = 3
, the smallest possible
c
is 2. For
c
= 2
, the smallest possible
n
0
=
15
which
follows from the requirement that
2
f
(
n
0
)
≥
4
.
�
(c)
f
(
n
) = 1 + (
n
sin(