GATE / CS ARCHIVE

GATE CSE 2000 / QUESTION 2.19

Consecutive DFS discoveries

Algorithms · Graph Algorithms · Full GATE CSE 2000 paper

GATE 2000, Q2.19 2 marks · MCQ
Report issue

Graph Algorithms

Question 2.19, GATE 2000: In undirected DFS, u is discovered and v is the next newly discovered vertex. Which is always true? The options assert a direct edge with ancestry, or that absent edge implies u is a leaf, or that absent edge implies the same parent.
Question 2.19, GATE 2000: In undirected DFS, u is discovered and v is the next newly discovered vertex. Which is always true? The options assert a direct edge with ancestry, or that absent edge implies u is a leaf, or that absent edge implies the same parent.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: If u has an unvisited neighbor when its exploration begins, DFS immediately follows an edge to such a neighbor. Then the next discovery v is adjacent and becomes a child of u.

Step 2: If the next discovery is not adjacent to u, DFS must have exhausted u without discovering any child and backtracked to an ancestor before reaching v. Therefore u is a leaf in the DFS tree, proving C.

The backtrack may cross several ancestors, so u and v need not share a parent. The two options requiring adjacency in every case are also too strong.

Original paper, page 5