GATE 2026 set1 Computer Science and Information Technology question: Consider the following pseudocode for depth-first search (DFS) algorithm which takes a…
Consider the following pseudocode for depth-first search (DFS) algorithm which takes a directed graph as input, where and are the discovery time and finishing time, respectively, of the vertex .
DFS(G):
unmark all v ∈ V
t ← 0
for each v ∈ V
if v is unmarked
t ← Explore(G, v, t)
end if
end for
Explore(G, v, t):
mark v
t ← t + 1
d[v] ← t
for each (v, w) ∈ E
if w is unmarked
t ← Explore(G, w, t)
end if
end for
t ← t + 1
f[v] ← t
return t
Suppose that the input directed graph is a directed acyclic graph (DAG). For an edge , which of the following options will NEVER be correct?
Show answer
Official answer: B,D