This preview shows pages 1–2. Sign up to view the full content.
CSE450/598 Design And Analysis of Algorithms
HW01 Grading Keys
1. (10 pts) Let
f
(
n
) = 0
.
01
n
2
and
g
(
n
) = 1000
×
n
×
log
2
(
n
+ 3). Find the smallest integer
N
≥
0 such that
f
(
N
)
≤
g
(
N
) but
f
(
N
+ 1)
> g
(
N
+ 1). Show the values of
N
,
f
(
N
),
g
(
N
),
f
(
N
+ 1) and
g
(
N
+ 1).
Grading Keys:
2 pts for each of the following ﬁve values.
N
= 2100210
, f
(
N
) = 44108820441
, g
(
N
) = 44108829304
. f
(
N
+ 1) = 44108862445
, g
(
N
+
1) = 44108851749
.
2. (10 pts) Prove or disprove Θ(
n
3
) +
O
(
n
4
) = Θ(
n
4
).
Θ(
n
3
) +
O
(
n
4
) = Θ(
n
4
) is
not
true.
Proof:
Let
f
(
n
) =
n
3
,
g
(
n
) =
n
2
. Then we have
f
(
n
)
∈
Θ(
n
3
) and
g
(
n
)
∈
O
(
n
4
). However,
f
(
n
) +
g
(
n
)
6∈
Θ(
n
4
).
2
Grading Keys:
4 pts for the correct conclusion.
6 pts each for the counter example.
3. (10 pts) Exercise 3.5 (p.108)
Solutions:
Let
n
(
T
) denote the number of nodes in
T
. Let
n
0
(
T
) denote the number of
leaf nodes in
T
. Let
n
1
(
T
) denote the number of nodes in
T
that has exactly one child.
Let
n
2
(
T
) denote the number of nodes in
T
that has exactly two children. Then
n
(
T
) =
n
0
(
T
) +
n
1
(
T
) +
n
2
(
T
). We need to show that for any binary tree
T
, we have
n
2
(
T
) =
n
0
(
T
)

1
.
We prove this by induction on the number of nodes in the binary tree
T
.
When
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 '08
 GuoliangXue
 Algorithms

Click to edit the document details