GATE CSE 2026 Session 1 Q50: Impossible DFS discovery/finish orderings for a DAG edge
- Algorithms
- 2 marks
- MSQ
- No negative marking
Question
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 tSuppose that the input directed graph is a directed acyclic graph (DAG).
For an edge , which of the following options will NEVER be correct?
Try it: multiple select: one or more correct options
Show answer and explanation
Answer: B, D (official GATE 2026 final answer key)
Concept used: Parenthesis theorem plus edge classification: a DAG has no back edges, so for every edge .
First step: Option B nests inside , which makes a back edge; option D interleaves intervals, which DFS never produces.
Full step-by-step solution
Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.
Share this question
Source: official GATE 2026 Session 1 CS question paper and final answer key, organised by IIT Guwahati. Question paper · Answer key
More Algorithms PYQs
- 2026 Session 1 · Q17Solve nested recurrences T1 = 4T1(n/2) + T2, T2 = 5T2(n/4) + log n
- 2026 Session 1 · Q41Shortest paths with at most k edges: two statements
- 2026 Session 1 · Q47Condition forcing a vertex into every minimum vertex cover
- 2026 Session 1 · Q49Cycle and cut properties of MSTs with distinct weights
- 2026 Session 1 · Q55Properties of 2-colorable (bipartite) graphs
- 2026 Session 2 · Q24Order n^(1/3), log n, log(n!), 2^(log n) by growth rate