hw_sol_01 - CS 473: Fundamental Algorithms, Spring 2011 HW...

Info iconThis preview shows pages 1–3. 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: CS 473: Fundamental Algorithms, Spring 2011 HW 1 Homework is due by Monday, 23:59:59, January 3 1 Problem 1 is due by Sunday, 23:59:59, January 30 1. (30 pts.) Short questions to be answered on compass individually. 2. (10 pts.) Present an algorithm that takes an undirected graph, and directs each one of the edges of the graph such that the resulting directed graph is a DAG . What is the running time of your algorithm? Solution : Run DFS on the given undirected graph G . Recall that we will have only tree edges or forward edges; sometimes undirected forward edges are called backward edges. Orient all edges so that they point out toward leaves. Let G be the resulting directed graph. Since a directed cycle in G can come only from an undirected cycle in G , it suffices show the following: Consider any (undirected) cycle C in G . Then there are two edges in C that have the same end point after being oriented. In the cycle C , consider a forward edge uv and its adjacent (tree) edge wv . Our algorithm indeed orient uv and wv such that they share their endpoint. Since orienteering each edge takes O (1) time, the total running time is O ( m + n ). Rubrik : (6 pts.): if the writeup gives a correct algorithm. (3 pts.): if the writeup gives a correct proof. (1 pts.): if the algorithm has a running time of O ( m + n ). 3. (40 pts.) For a DAG G let lp( v,G ) denote the longest directed path in G that starts in v (if there are several such paths, we arbitrarily choose one of them). Here, the length of a path is the number of edges in it. The influence of a vertex v in G , denoted by i ( v ), is the number of edges of lp( v,G ). Two vertices x and y in a DAG G are unrelated if there is no directed path from x to y , and no directed path from y to x in G . (a) (5 pts.) Prove, that if the edge ( x,y ) is in G then i ( x ) > i ( y ). 1 Solution : Consider the path combining the edge xy and the path lp( y,G ); this is indeed a path since the graph G is a DAG. It starts with x and has a length i ( y ) + 1, so we have i ( x ) i ( y ) + 1 > i ( y ). Rubrik : (3 pts.): if the writeup gives a key proof idea that could lead to the correct proof. (2 pts.): if the writeup gives a correct proof. (b) (5 pts.) Prove, that if there is a path between x and y in G then i ( x ) > i ( y ). Solution : Consider the path combining a path from x to y and the path lp( y,G ). As mentioned above, it is indeed a path, since the underlying graph is a DAG. It starts with x and has a length of at least i ( y ) + 1, so we have i ( x ) i ( y ) + 1 > i ( y ). Rubrik : (3 pts.): if the writeup gives a proof idea that could lead to the correct proof. (2 pts.): if the writeup gives a correct proof....
View Full Document

This note was uploaded on 04/18/2011 for the course CS 473 taught by Professor Chekuri,c during the Spring '08 term at University of Illinois, Urbana Champaign.

Page1 / 7

hw_sol_01 - CS 473: Fundamental Algorithms, Spring 2011 HW...

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

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