CS3230
Tutorial 2
1. Which of the following recurrence relations can be solved using the master theorem? If it
cannot be solved, state so. If it can be solved, give the answer (in terms of Θ notation)
and state which clause of the master theorem applies.
(a)
T
(
n
) = 15
T
(
n/
3) +
n
3
.
Ans: Yes.
a
= 15,
b
= 3,
k
= 3,
b
k
= 3
3
> a
. Thus,
T
(
n
) = Θ(
n
3
).
(b)
T
(
n
) = 3
T
(
n/
2) +
n
.
Ans:
a
= 3
, b
= 2
, k
= 1. Thus,
a > b
k
.
Thus,
T
(
n
) = Θ(
n
log
2
3
).
(c)
T
(
n
) = 4
T
(
n/
2) +
n
2
.
Ans:
a
= 4
, b
= 2
, k
= 2. Thus,
a
=
b
k
.
Thus,
T
(
n
) = Θ(
n
2
log
n
).
(d)
T
(
n
) =
T
(
n/
3) +
T
(2
n/
3) +
n
.
Ans: No.
(e)
T
(
n
) = 4
T
(
n/
3) +
n
log
n
.
Ans:
Yes, by taking
a
= 4
, b
= 3
, k
= 1 +
, where 1
<
1 +
< log
3
4, we see that
n
1
≤
f
(
n
)
≤
n
1+
, for large enough
n
.
Thus,
T
(
n
) =
O
(
n
log
3
4
).
Similarly, as
f
(
n
) = Ω(
n
), we have that
T
(
n
) = Ω(
n
log
3
4
).
Giving us
T
(
n
) = Θ(
n
log
3
4
).
2. Use induction to detmine the upper bound for the following recurrence relations. Express
your answer in big
O
notation.
(a)
T
(
n
) = 2 +
∑
n

1
i
=1
T
(
i
);
T
(1) = 1.
Ans: We show by induction that
T
(
n
)
≤
2
*
2
n
, for
n
≥
1.
Base case: For
n
= 1, the relation clearly holds.
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.
 Fall '10
 sanjay
 Algorithms, Big O notation, Bk, binary insertion sort

Click to edit the document details