This preview shows pages 1–3. Sign up to view the full content.
This fle contains the exercises, hints, and solutions For Chapter 8 oF the
book ”Introduction to the Design and Analysis oF Algorithms,” 2nd edition, by
A. Levitin. The problems that might be challenging For at least some students
are marked by
±
;
those that might be diﬃcult For a majority oF students are
marked by
²
.
Exercises 8.1
1. a. What does dynamic programming have in common with divideand
conquer?
b. What is a principal di±erence between the two techniques?
2. a. Compute
C
(6
,
3)
by applying the dynamic programming algorithm.
b. Is it also possible to compute
C
(
n,k
)
by flling the algorithm’s dy
namic programming table column by column rather than row by row?
3. Prove the Following assertion made in the text while investigating the time
eﬃciency oF the dynamic programming algorithm For computing
C
(
)
:
(
k
−
1)
k
2
+
k
(
n
−
k
)
∈
Θ(
nk
)
.
4. a. What is the space eﬃciency oF
Binomial,
the dynamic programming
algorithm For computing
C
(
)
?
b. Explain how the space eﬃciency oF this algorithm can be improved.
(Try to make as much oF an improvement as you can.)
5. a. ²ind the order oF growth oF the Following Functions:
i.
C
(
n,
1)
ii.
C
(
n,
2)
iii.
C
(
n, n/
2)
For even
n
’s.
b. What major implication For computing
C
(
)
do the answers to the
questions in part (a) have?
6. ²ind the exact number oF additions made by the Following recursive algo
rithm based directly on Formulas (8.3) and (8.4).
Algorithm
BinomCoef
(
)
if
k
=0
or
k
=
n
return
1
else return
BinomCoef
(
n
−
1
,k
−
1)+
BinomCoef
(
n
−
1
)
7. Which oF the Following algorithms For computing a binomial coeﬃcient is
most eﬃcient?
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Documenta. Use the formula
C
(
n,k
)=
n
!
k
!(
n
−
k
)!
.
b. Use the formula
C
(
n, k
n
(
n
−
1)
...
(
n
−
k
+1)
k
!
.
c. Apply recursively the formula
C
(
C
(
n
−
1
,k
−
1) +
C
(
n
−
1
)
for
n>k>
0
,
C
(
n,
0)
=
C
(
n,n
)=1
.
d. Apply the dynamic programming algorithm.
8. Prove that
C
(
C
(
−
k
)
for
n
≥
k
≥
0
and explain how this formula can be utilized in computing
C
(
)
.
9.
Shortest path counting
A chess rook can move horizontally or vertically
to any square in the same row or in the same column of a chessboard.
Find the number of shortest paths by which a rook can move from one
corner of a chessboard to the diagonally opposite corner [Gar78], p.10
(a) by a dynamic programming algorithm.
(b) by using elementary combinatorics.
10.
±
World Series odds
Consider two teams,
A
and
B
, playing a series of
games until one of the teams wins
n
games. Assume that the probabil
ity of
A
winning a game is the same for each game and equal to
p
and
the probability of
A
losing a game is
q
=1
−
p.
(Hence, there are no
ties.)
Let
P
(
i,j
)
be the probability of
A
winning the series if
A
needs
i
moregamestowintheseriesand
B
needs
j
more games to win the series.
a. Set up a recurrence relation for
P
(
)
that can be used by a dy
namic programming algorithm.
This is the end of the preview. Sign up
to
access the rest of the document.
 Spring '10
 DrT
 Algorithms

Click to edit the document details