

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: Fundamental Algorithms; Subject: Computer Science; University: Wellesley College; Term: Spring 2001;
Typology: Assignments
1 / 3
This page cannot be seen from the preview
Don't miss anything!


CS231 Algorithms Handout # Prof Lyn Turbak April 19, 2001 Wellesley College
PROBLEM SET 8 Due: Thursday, April 26
Reading: Handouts 25--26; CLR Section 5.4 (Graphs); Sections 23.1--23.2 (Bread-First Search); Chapter 24 (Minimum Spanning Trees); Sections 25.1 -- 25.2 (Relaxation + Dijkstra’s algorithm). I suggest you skim all the sections and look at the figures but avoid reading the proofs. Note that some of the graph algorithms I presented in class are somewhat different than the ones presented in the book.
Suggested Problems: 23.1-1; 24.1-7, 24.2-4, 24.2-5, 25.2-1, 25.2-3, 25.2-5, 25.2-
Problem 1 [50] Consider the following weighted graph G:
Although edges in the graph are directed (draw with arrows), for this problem you should ignore the arrows and treat G as an undirected graph. (Sorry, but the latest version of Microsoft Word prevents me from conveniently editing the graph, which was created in a previous version.)
In the following problems, you should assume that G is represented as a collection of adjacency lists, and that vertices are ordered alphabetically within each adjacency list.
a [10] Use Prim's algorithm to derive a minimum spanning tree of G.
b [10] Use Kruskal's algorithm to derive a minimum spanning tree of G.
c [10] Draw the tree that is induced by performing breadth-first search starting at node d.
d [20] Use Dijkstra’s algorithm to determine the shortest paths from d to each of the other vertices. Draw the shortest path tree that is induced by running Dijkstra's algorithm, and annotate each vertex by its shortest path distance from d.
Problem 2 [10] (CLR 23.2-5, p. 476)
Problem 3 [15] (CLR 23.2-6, p. 476) (See CLR p. 89 for a definition of a bipartite graph, and CLR p. 601 for a picture of one.)
Problem 4 [15] (CLR 24.2-6, p. 510)
Problem 5 [10] (A modified version of CLR 25.2-2, p. 531)
Dijkstra's algorithm assumes that the edge weights of the given graph are non-negative. Here we consider some of the consequences of allowing negative edge weights.
a [5] A negative-weight cycle of a weighted graph is a cyclic path whose path weight is negative. Suppose that G is a directed graph with a negative-weight cycle. Explain why the single-source shortest path problem may not be well-defined on such a graph.
b [5] If a graph G has some edges with negative weights but no negative-weight cycles, then the single-source shortest path problem is still well-defined. However, Dijkstra's algorithm is not guaranteed to correctly solve the problem in the presence of negative edge weights. Construct a connected, directed, weighted graph with four vertices such that Dijkstra's algorithm gives an incorrect solution to the single-source shortest path problem.
Extra Credit Problem [20] CLR 24.2-8 (p. 510)