|
CS 3343/3341 Analysis of Algorithms Spring 2012 Recitation 10 Graph Search Very Partial Answers |
"Exercise 22.4-5, page 615: Another way to perform topological sorting on a directed acyclic graph G = (V, E) is to repeatedly find a vertex of in-degree 0, output it, and remove it and all its outgoing edges from the graph. Explain how to implement this idea so that it runs in time O(V + E). What happens to this algorithm if G has cycles?" [Here "in-degree" of a given vertex means the number of edges coming into the vertex.]