# Question: Another way to perform topological sorting on a directed

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 of 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?

**View Solution:**## Answer to relevant Questions

Give an O (V + E)-time algorithm to compute the component graph of a directed graph G = (V, E). Make sure that there is at most one edge between two vertices in the component graph your algorithm produces.Let G = (V, E) be a directed graph in which each vertex u ¬ V is labeled with a unique integer L(u) from the set {1, 2,..., |V|}. For each vertex u ¬ V, let R(u) = (v ε V : u → v) be the set of ...The compressor in a refrigerator takes refrigerant R-134a in at 100 kPa, 20C and compresses it to 1 MPa, 40C. With the room at 20C find the minimum compressor work.A 2-kg/s flow of steam at 1 MPa, 700C should be brought to 500C by spraying in liquid water at 1 MPa, 20C in an SSSF setup. Find the rate of irreversibility, assuming that surroundings are at ...Water as saturated liquid at 200 kPa goes through a constant pressure heat exchanger. The heat input is supplied from a reversible heat pump extracting heat from the surroundings at 17C. The water flow rate is 2 ...Post your question