GATE | Gate IT 2007 | Question 24

A depth-first search is performed on a directed acyclic graph. Let d[u] denote the time at which vertex u is visited for the first time and f[u] the time at which the dfs call to the vertex u terminates. Which of the following statements is always true for all edges (u, v) in the graph ?
(A) d[u] < d[v] (B) d[u] < f[v] (C) f[u] < f[v] (D) f[u] > f[v]

Answer: (D)

Starting DFS at node V
1] Visit(V) -> DFS(X) ->Visit(X) ->DFS(U) ->Visit(U) -> backtrack(X) -> backtrack(V)
Therefore: d[U] > d[V], d[U] < f[V], f[U] < f[V]
But, visiting order is just opposite of finishing order.
Hence f[U] > f[V]

Quiz of this Question

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.