This preview shows pages 1–3. Sign up to view the full content.
CS170  Spring 2010
HW2  Solutions
1. (DPV 2.5)
a)
T
(
n
) = 2
T
(
n/
3) + 1 = Θ(
n
log
3
2
) by the Master theorem.
b)
T
(
n
) = 5
T
(
n/
4) +
n
= Θ(
n
log
4
5
) by the Master theorem.
c)
T
(
n
) = 7
T
(
n/
7) +
n
= Θ(
n
log
n
) by the Master theorem.
d)
T
(
n
) = 9
T
(
n/
3) +
n
2
= Θ(
n
2
log
n
) by the Master theorem.
e)
T
(
n
) = 8
T
(
n/
2) +
n
3
= Θ(
n
3
log
n
) by the Master theorem.
f)
T
(
n
) = 49
T
(
n/
25) +
n
3
/
2
log
n
= Θ(
n
3
/
2
log
n
).
By using the same reasoning used in the proof of the Master Theorem, we see that at level
i
of the recursion we have 49
i
·
(
n
(25)
i
)
3
/
2
·
log
(
n
25
i
)
=
(
49
25
3
/
2
)
i
·
n
3
/
2
·
(log
n

i
·
log25). Since
∑
log
25
n
i
=0
(
49
25
3
/
2
)
i
= Θ(1) we see our expression is
O
(
n
3
/
2
log
n
). Also,
T
(
n
) is clearly Ω(
n
3
/
2
log
n
),
since this is a lower bound on the running time of the ﬁrst level of the recursion.
g)
T
(
n
) =
T
(
n

1) + 2 = Θ(
n
). Since
T
(
n
) =
∑
n
i
=0
2.
h)
T
(
n
) =
T
(
n

1) +
n
c
=
∑
n
i
=0
i
c
= Θ(
n
c
+1
) (
c
≥
1 is a constant). Shown in HW1.
i)
T
(
n
) =
T
(
n

1) +
c
n
=
∑
n
i
=0
c
i
= Θ(
c
n
) (
c >
1 is a constant). Shown in HW1.
j)
T
(
n
) = 2
T
(
n

1) + 1 =
∑
n
i
=0
2
i
·
Θ(1) = Θ(2
n
).
j)
T
(
n
) =
T
(
√
n
) + 1 = Θ(loglog
n
).
In each level of the recursion we have one process which takes
O
(1). Therefore
T
(
√
n
) + 1 =
∑
k
i
=0
1+
T
(
b
) where
b
is some small enough constant and
k
is the number of levels of the recursion
taken to reach
b
from
n
. We need to ﬁnd
k
, and plug it into the equation
∑
k
i
=0
1+
T
(
b
) to compute
the running time.
At step
i
of the recursion the input is of size
n
(
1
2
i
)
. We need to ﬁnd
k
such that
n
(
1
2
k
)
=
b
. Doing
the math we get
k
=
loglog
n

loglog
b
log2
= Θ(loglog
n
), and we see that
T
(
n
) =
∑
k
i
=0
1 +
T
(
b
) =
Θ(loglog
n
).
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document2. (DPV 2.11)
Let
X
=
±
A B
C
D
²
and
Y
=
±
E
F
G H
²
be two
n
by
n
matrices, where
A,B,C,D,E,F,G
and
H
are
n/
2by
n/
2 submatrices.
For any
i
≤
n
2
and
j
≤
n
2
:
(
X
·
Y
)
ij
=
n
X
k
=1
X
ik
·
Y
kj
=
n/
2
X
k
=1
X
ik
·
Y
kj
+
n
X
k
=
n
2
+1
X
ik
·
Y
kj
=
n/
2
X
k
=1
A
ik
·
E
kj
+
n/
2
X
k
=1
B
ik
·
G
kj
= (
A
·
E
+
B
·
G
)
ij
A similar proof holds for the values of (
i,j
) in the other sectors of the matrix.
3. (DPV 2.15)
This is the end of the preview. Sign up
to
access the rest of the document.
 Spring '02
 HENZINGER
 Algorithms

Click to edit the document details