Introduction to Algorithms
November 15, 2004
Massachusetts Institute of Technology
6.046J/18.410J
Professors Piotr Indyk and Charles E. Leiserson
Handout 26
Problem Set 6 Solutions
Reading:
Chapters 22, 24, and 25.
Both exercises and problems should be solved, but
only the problems
should be turned in.
Exercises are intended to help you master the course material. Even though you should not turn in
the exercise solutions, you are responsible for material covered in the exercises.
Mark the top of each sheet with your name, the course number, the problem number, your
recitation section, the date and the names of any students with whom you collaborated.
You will often be called upon to “give an algorithm” to solve a certain problem. Your writeup
should take the form of a short essay. A topic paragraph should summarize the problem you are
solving and what your results are. The body of the essay should provide the following:
1. A description of the algorithm in English and, if helpful, pseudocode.
2. At least one worked example or diagram to show more precisely how your algorithm works.
3. A proof (or indication) of the correctness of the algorithm.
4. An analysis of the running time of the algorithm.
Remember, your goal is to communicate. Full credit will be given only to correct algorithms
which are
which are described clearly
. Convoluted and obtuse descriptions will receive low marks.
Exercise 61.
Do Exercise 22.25 on page 539 in CLRS.
Exercise 62.
Do Exercise 22.43 on page 552 in CLRS.
Exercise 63.
Do Exercise 22.57 on page 557 in CLRS.
Exercise 64.
Do Exercise 24.13 on page 591 in CLRS.
Exercise 65.
Do Exercise 24.32 on page 600 in CLRS.
Exercise 66.
Do Exercise 24.48 on page 606 in CLRS.
Exercise 67.
Do Exercise 25.26 on page 635 in CLRS.
Exercise 68.
Do Exercise 25.35 on page 640 in CLRS.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
2
Handout 26: Problem Set 6 Solutions
Problem 61. Truckin’
Professor Almanac is consulting for a trucking company. Highways are modeled as a directed
graph
G
= (
V, E
)
in which vertices represent cities and edges represent roads. The company is
planning new routes from San Diego (vertex
s
) to Toledo (vertex
t
).
(a)
It is very costly when a shipment is delayed en route. The company has calculated the
probability
p
(
e
)
∈
[0
,
1]
that a given road
e
∈
E
will close without warning. Give an
efficient algorithm for finding a route with the minimum probability of encountering
a closed road. You should assume that all road closings are independent.
Solution:
To simplify the solution, we use the probability
q
(
e
)
= 1
−
p
(
e
)
that a road will be
open. Further, we remove from the graph roads with
p
(
e
)
= 1
, as they are guaranteed
to be closed and will never be included in a meaningful solution. (Following this
transformation, we can use depth first search to ensure that some path from
s
to
t
has a positive probability of being open.) By eliminating
p
(
e
)
= 1
, we now have
0
< q
(
e
)
≤
1
for all edges
e
∈
E
. It is important to have eliminated the possibility of
q
(
e
)
= 0
, because we will be taking the logarithm of this quantity later.
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '08
 ErikDemaine
 Algorithms, Graph Theory, Shortest path problem, BellmanFord

Click to edit the document details