Last modified:

**Assigned:**
Wed 02 Dec 2009

**Due:**
Wed 09 Dec 2009

- Please review the course syllabus and make sure that you understand the course policies for grading, late homework, and academic honesty.
- On the
*first page*of your solution write-up, you*must*make explicit which problems are to be graded for "regular credit", which problems are to be graded for "extra credit", and which problems you did not attempt. Please use a table something like the followingProblem 01 02 03 04 05 06 07 08 09 ... Credit RC RC RC EC RC RC NA RC RC ... where "RC" is "regular credit", "EC" is "extra credit", and "NA" is "not applicable" (not attempted). Failure to do so will result in an arbitrary set of problems being graded for regular credit, no problems being graded for extra credit, and a five percent penalty assessment.

- You must also write down with whom you worked on the assignment. If this changes from problem to problem, then you should write down this information separately with each problem.

**Required:** Do five of the six problems below.

Unless otherwise indicated, exercises and problems are from *Introduction to Algorithms* by Cormen, Leiserson, Rivest, and Stein. The edition (2^{nd} or 3^{rd}) will be indicated if the numbering differs. * - Indicates problem from *Algorithms* by Dasgupta, Papadimitriou, and Vazirani.

- 24.5-2
- Solve problem 5 on homework 5 by using a graph algorithm for determining shortest paths. Argue that your solution is correct, and analyze its running time. (Hint: You will have one vertex in your graph corresponding to each city.)
- * Often there are multiple shortest paths between two nodes of a graph. Give a linear-time algorithm for the following task.
*Input:*Undirected graph*G = (V,E)*with unit edge lengths; nodes*u, v ∈ V*.

*Output:*The number of distinct shortest paths from*u*to*v*. - * Give an algorithm that takes as input a directed graph with positive edge lengths, and returns the length of the shortest cycle in the graph. ( If the graph is acyclic, it should say so.) Your algorithm should take time at most
*O*(|*V*^{3}|). - * Give an
*O*(|*V*^{2}|) algorithm for the following task.*Input:*Undirected graph*G = (V,E)*with edge lengths*l*> 0; an edge_{e}*e ∈ E*.

*Output:*The length of the shortest cycle containing*e*. - *
*Generalized shortest-paths problem.*In Internet routing, there are delays on lines but also, more significantly, delays at routers. This motivates a generalized shortest-paths problem.Suppose that in addition to having edge lengths {

*l*:_{e}*e ∈ E*}, a graph also has vertex costs {*c*:_{v}*v ∈ V*}. Now define the cost of a path to be the sum of its edge lengths, plus the costs of all vertices on the path (including the endpoints). Give an efficient algorithm for the following problem.*Input:*A directed graph*G = (V, E)*; positive edge lengths*l*and positive vertex costs_{e}*c*; a starting vertex_{v}*s ∈ V*.

*Output:*An array cost[⋅] such that for every vertex*u*, cost[*u*] is the least cost of any path from*s*to*u*(i.e., the cost of the cheapest path), under the definition above.Notice that cost[

*s*] =*c*._{v}

Harriet Fell

College of Computer Science, Northeastern University

360 Huntington Avenue #340 WVH,

Boston, MA 02115

Email: fell@ccs.neu.edu

Phone: (617) 373-2198 / Fax: (617) 373-5121

The URL for this document is: http://www.ccs.neu.edu/home/fell/CS5800/F09/Homeworks/hw.09.html