2
Handout 7: Problem Set 1 Solutions
(a)
f
(
n
)
=
O
(
g
(
n
))
and
g
(
n
)
=
O
(
f
(
n
))
implies that
f
(
n
)
=
(
g
(
n
))
.
Solution:
This Statement is True.
Since
f
(
n
)
=
O
(
g
(
n
))
, then there exists an
n
0
and a
c
such that for all
n
√
n
0
,
f
(
n
)
←
Similarly, since
g
(
n
) =
O
(
f
(
n
))
, there exists an
n
0
and a
c
such that for all
cg
(
n
)
.
f
(
n
)
. Therefore, for all
n
√
max(
n
0
, n
Hence,
f
(
n
)
=
(
g
(
n
))
.
(
)
g n
,
0
←
)
,
0
c
1
g
(
n
)
←
f
(
n
)
←
cg
(
n
)
.
n
√
n
c
0
(b)
f
(
n
)
+
g
(
n
)
=
(max(
f
(
n
)
, g
(
n
)))
.
Solution:
This Statement is True.
For all
n
√
1
,
f
(
n
)
←
max(
f
(
n
)
, g
(
n
))
and
g
(
n
)
←
max(
f
(
n
)
, g
(
n
))
. Therefore:
f
(
n
)
+
g
(
n
)
←
max(
f
(
n
)
, g
(
n
))
+
max(
f
(
n
)
, g
(
n
))
←
2
max(
f
(
n
)
, g
(
n
))
and so
f
(
n
)
+
g
(
n
) =
O
(max(
f
(
n
)
, g
(
n
)))
. Additionally, for each
n
, either
f
(
n
)
√
max(
f
(
n
)
, g
(
n
))
or else
g
(
n
)
√
max(
f
(
n
)
, g
(
n
))
. Therefore, for all
n
√
1
,
f
(
n
)
+
g
(
n
)
√
max(
f
(
n
)
, g
(
n
))
and so
f
(
n
)
+
g
(
n
)
=
±(max(
f
(
n
)
, g
(
n
)))
. Thus,
f
(
n
)
+
g
(
n
)
=
(max(
f
(
n
)
, g
(
n
)))
.
(c)
Transitivity:
f
(
n
)
=
O
(
g
(
n
))
and
g
(
n
)
=
O
(
h
(
n
))
implies that
f
(
n
)
=
O
(
h
(
n
))
.
Solution:
This Statement is True.
Since
f
(
n
) =
O
(
g
(
n
))
, then there exists an
n
0
and a
c
such that for all
n
√
n
0
,
)
f
(
)
n
,
0
←
(
)
g n
,
0
←
f
(
n
)
←
cg
(
n
)
. Similarly, since
g
(
n
)
=
O
(
h
(
n
))
, there exists an
n
h
(
n
)
. Therefore, for all
n
√
max(
n
0
, n
and a
c
such that
for all
n
√
n
Hence,
f
(
n
)
=
O
(
h
(
n
))
.