Question

Let GG be a directed graph and TT a depth first search (DFS) spanning tree in GG that is rooted at a vertex vv. Suppose TT is also a breadth first search (BFS) tree in GG, rooted at vv. Which of the following statements is/are TRUE for every such graph GG and tree TT ?

Choose every correct option
Official answer and solution
Official answer
C
From
Official GATE 2024 answer key

Solution

Use the BFS tree level property d(y)≤d(x)+1d(y) \le d(x) + 1 for every directed edge (x,y)∈E(G)(x, y) \in E(G) to rule out forward edges.

Let d(u)d(u) denote the depth (distance from the root vv) of vertex uu in the spanning tree TT. Since TT is a BFS tree of GG rooted at vv, every directed edge (x,y)(x, y) in GG must satisfy:

d(y)≤d(x)+1d(y) \le d(x) + 1
  • Forward-edges (C): With respect to the DFS tree TT, a forward-edge (x,y)(x, y) is a non-tree edge from an ancestor xx to a proper descendant yy, which means d(y)≥d(x)+2d(y) \ge d(x) + 2. This contradicts the BFS property d(y)≤d(x)+1d(y) \le d(x) + 1. Hence there can be no forward-edges in GG with respect to TT, so (C) is TRUE.
  • Back-edges (A) and Cross-edges (B): A back-edge goes from a descendant xx to an ancestor yy (d(y)≤d(x)≤d(x)+1d(y) \le d(x) \le d(x) + 1), and a cross-edge between two children of vv has d(y)=d(x)=1≤d(x)+1d(y) = d(x) = 1 \le d(x) + 1. Both are compatible with TT being both a DFS tree and a BFS tree, so (A), (B), and (D) are FALSE.
Final answer

Option (C)

Common trap

Confusing undirected BFS/DFS trees with directed graphs where back-edges and cross-edges between siblings can still exist.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2024 Computer Science and Information Technology - Set 1 (CS1)
Question
45 of 65
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.