Let ๐บ be a directed graph and ๐‘‡ a depth first search (DFS) spanning tree inโ€ฆ

2024

Let ๐บ be a directed graph and ๐‘‡ a depth first search (DFS) spanning tree in ๐บ that is rooted at a vertex ๐‘ฃ. Suppose ๐‘‡ is also a breadth first search (BFS) tree in ๐บ, rooted at ๐‘ฃ. Which of the following statements is/are TRUE for every such graph ๐บ and tree ๐‘‡ ?ย ย ย ย 

  1. A.

    There are no back-edges in ๐บ with respect to the tree ๐‘‡

  2. B.

    There are no cross-edges in ๐บ with respect to the tree ๐‘‡

  3. C.

    There are no forward-edges in ๐บ with respect to the tree ๐‘‡

  4. D.

    The only edges in ๐บ are the edges in ๐‘‡

Attempted by 89 students.

Show answer & explanation

Correct answer: C

Key insight: a BFS tree records shortest-path distances (levels) from the root, so any edge between an ancestor and a descendant is tightly constrained by those levels.

  • No forward-edges: If there were an edge from an ancestor u to a descendant w, the edge gives a path of length depth[u]+1 to w, so BFS forces depth[w] โ‰ค depth[u]+1. Since w is strictly deeper than u, depth[w] = depth[u]+1, so u must be the parent of w in T. Hence any ancestorโ†’descendant edge is a tree edge, so non-tree forward-edges cannot occur.

  • Back-edges can exist: For example, tree edges v โ†’ a โ†’ b together with an extra edge b โ†’ v form a back-edge. Levels remain 0,1,2 so T is still a BFS tree and a DFS that follows the tree edges produces the same DFS tree.

  • Cross-edges can exist: For example, tree edges v โ†’ a and v โ†’ b plus an extra edge a โ†’ b. By choosing a DFS ordering that visits b before a, the DFS tree can be the same as the BFS tree (v is parent of both a and b) while a โ†’ b is classified as a cross-edge.

Conclusion: The only statement that must hold for every such G and T is that there are no forward-edges (non-tree ancestorโ†’descendant edges).

A video solution is available for this question โ€” log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir