Professional Documents
Culture Documents
Leonard J. Schulman
Problem set 8 Due Friday May 28 at 5pm in the Intel Lab
1. (10 points)
Let G = (V ; E ) be an undirected graph. Give an O(V + E )-time algorithm to compute a path in G that
traverses each edge in E exactly once in each direction. Describe how you can find your way out of a
maze if you are given a large supply of pennies.
2. (10 points)
Give an example of a directed graph G = (V ; E ), a source vertex s 2 V , and a set of tree edges E E
such that for each vertex v 2 V , the unique path in E from s to v is a shortest path in G, yet the set
of edges E cannot be produced by running BFS on G, no matter how the vertices are ordered in each
adjacency list.
(The order in the adjacency list simply specifies the order in which the edges out of each vertex are
processed by BFS. I didnt discuss adjacency lists in class but see the discussion of adjacency lists and
adjacency matrices in the notes for lectures 8-9 of the Berkeley course.)
3. (10 points) [No collaboration]
The road map of an ancient kingdom is represented by a weighted directed graph G = (V ; f ) where
f : V V ! [0; 1 represents the probability that a messenger traveling along that road, will be killed
by highwaymen or wild animals. (The highwaymen might preferentially prey on travelers going
in one directionality or another, since this influences their estimate of the potential loot.) You may
assume that the probability of this sad event is independent for each road. The king, situated at city
s, wishes to know, for each city of the kingdom, the safest route along which a messenger can be sent
1
vertices in the desired order. But you dont have to be able to compute pre-visit times, parents,
or post-visit times of vertices.
In short: you have O(log n) read-write memory at your disposal. Your algorithm is to traverse the
graph. The algorithm is equipped with a write-only output tape on which, as it works, it prints out
statements of the form I am now at vertex v . The printout should be identical to a printout which
you could have gotten from the usual DFS algorithm (possibly for some other ordering of the vertices
in the adjacency lists.)