CS 5114 Homework 2 (Spring 2008)
Assigned on Monday, February 4, 2008. Hardcopy due at the
beginning of class on Monday, February 11, 2008.
Describe your algorithms as clearly as possible. The style used in
the book is fine, as long as your description is not ambiguous. Do not
make any assumptions not stated in the problem. If you do make any
assumptions, state them clearly, and explain why the assumption does not
decrease the generality of your solution. Do not describe your
algorithms only for a specific example you may have worked out. You must
also provide a clear proof that your solution is correct (or a
counter-example, where applicable).
- (10 points) Solve exercise 2 in Chapter 4 (page 189) of your
textbook.
- (25 points) Solve exercise 13 in Chapter 4 (pages 194-195) of your
textbook.
- (30 points) Solve exercise 21 in Chapter 4 (page 200) of your
textbook. Note that you cannot sort the edges, since your algorithm
must run in O(n) time. (Hint: First solve exercise 2 in
Chapter 3 (page
107) of your textbook. If you like, you can give your algorithm for
this exercise some name, e.g., FindCycle, and use this
algorithm as a sub-routine for solving exercise 21 in Chapter 4.)
- (35 points) You are given a graph G(V, E) and a minimum
spanning tree (V, T) for G. You now pick an edge
e in E and change its cost from c to
c'. Describe an algorithm to update T so that it is
a minimum spanning tree for the graph with the new edge weight. Your
algorithm must run in time linear in the number of nodes and edges in
G. There are multiple cases to consider, depending on whether
e is in T or not and whether c is larger or
smaller than c'. You may find it useful to describe each case
separately. You can assume that all edge costs are distinct, both
before and after the change.