assignment2_tempsol - CSIS0250B - Sample solution for...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSIS0250B - Sample solution for Assignment 2 (2009-03-12) 1 Question 1 Question 1 Question 1 Question 1 For a general graph, the cost value of any two nodes in the same strongly connected component will be the same since both are reachable from each other. Hence, it is sufficient to run the below algorithm on the DAG of the strongly connected components of the graph. For a node corresponding to component C, we consider the cost of the node p ¡ ¢ min £¤¡ ¥p £ ¦. Algorithm. First of all, we topologically sort the DAG in linear time. Let v § , U v ¨ be the topological order. Then the following function finds the cost array in linear time. find_costs() ¥ for i ¢ n to 1 cost©v ª « ¢ p ¬ ­ for all (v ª , v ® ) ¤ ¯ if (cost°v ® ± ² cost©v ª «) (cost©v ª « ¢ cost°v ® ±) Question 2 Question 2 Question 2 Question 2 Define matrix D so that D ª® is the length of the shortest path from vertex i to vertex ³ in the input graph. Row i of the matrix can be computed by a run of Di³kstra’s algorithm in time ´(µ¶µ · ). S´ we can calculate all of the D in time ´(µ¶µ ¸...
View Full Document

This note was uploaded on 03/01/2010 for the course CS 1234 taught by Professor Chan during the Spring '10 term at University of the Bío-Bío.

Page1 / 2

assignment2_tempsol - CSIS0250B - Sample solution for...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online