This preview shows pages 1–2. Sign up to view the full content.
COP3530C.01, Spring 2001
S. Lang
Solution Key to Assignment #1 (40 pts.)
1/28/01
1.
(12 pts.)
Exercise 2.2 of the Text, do all parts and provide explanations as precisely as possible.
That is, give a proof for each “yes” answer, give a counter example for each “no” answer.
Suppose
T
1
(
n
) = O(
f
(
n
)) and
T
2
(
n
) = O(
f
(
n
)).
(a)
(3 pts.) Prove
T
1
(
n
) +
T
2
(
n
) = O(
f
(
n
)).
(Solution one)
Since
T
1
(
n
) = O(
f
(
n
)) by assumption, there exist constants
c
,
k
such that
T
1
(
n
)
≤
c
f
(
n
) when
n
≥
k
.
Similarly, there exist constants
c
’,
k
’ such that
T
1
(
n
)
≤
c
’
f
(
n
) when
n
≥
k
’.
When
n
≥
max(
k
,
k
’), adding the two inequalities yields
T
1
(
n
) +
T
2
(
n
)
≤
(
c
+
c
’)
f
(
n
), which
implies
T
1
(
n
) +
T
2
(
n
) = O(
f
(
n
)).
(Solution two)
T
1
(
n
) +
T
2
(
n
) = max(O(
f
(
n
)), O(
f
(
n
))), using Rule 1 of the Text
=
O(
f
(
n
)).
(b)
(3 pts.) Disprove
T
1
(
n
) –
T
2
(
n
) = o(
f
(
n
)) (the littleo).
We define a counter example as follows: Let
T
1
(
n
) = 2
n
,
T
2
(
n
) =
n
, and
f
(
n
) =
n
.
Thus,
T
1
(
n
) =
O(
f
(
n
)) because
T
1
(
n
) = 2
f
(
n
);
T
2
(
n
) = O(
f
(
n
)) because
T
2
(
n
) =
f
(
n
).
However, since
,
1
lim
)
(
)
(
)
(
lim
2
1
=
=

∞
→
∞
→
n
n
n
f
n
T
n
T
n
n
so
T
1
(
n
) –
T
2
(
n
)
≠
o(
f
(
n
)).
(c)
(3 pts.) Disprove
O(1).
)
(
)
(
2
1
=
n
T
n
T
We define a counter example as follows: Let
T
1
(
n
) =
n
2
,
T
2
(
n
) =
n
, and
f
(
n
) =
n
2
.
Thus,
T
1
(
n
) =
O(
f
(
n
)) because
T
1
(
n
) =
f
(
n
);
T
2
(
n
) = O(
f
(
n
)) because
T
2
(
n
) =
n
≤
n
2
=
f
(
n
).
However,
,
)
(
)
(
2
2
1
n
n
n
n
T
n
T
=
=
and
n
≠
O(1) because
n
is not bounded by any constant.
(d)
(3 pts.) Disprove
T
1
(
n
) = O(
T
2
(
n
)).
We define a counter example as follows: Let
T
1
(
n
) =
n
2
,
T
2
(
n
) =
n
, and
f
(
n
) =
n
2
.
Thus,
T
1
(
n
) =
O(
f
(
n
)) because
T
1
(
n
) =
f
(
n
);
T
2
(
n
) = O(
f
(
n
)) because
T
2
(
n
) =
n
≤
n
2
=
f
(
n
).
However,
T
1
(
n
)
≠
O(
T
2
(
n
)) because, if
T
1
(
n
) = O(
T
2
(
n
)) were true, that is, if
n
2
= O(
n
), we show this leads to a
contradiction.
From
n
2
= O(
n
), there exist constants
c
,
k
such that
n
2
≤
cn
when
n
≥
k
.
That is,
n
≤
c
for
n
≥
k
.
This is false when choosing
n
= max(
c
+ 1,
k
).
2.
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.