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 ๐ ?ย ย ย ย
- A.
There are no back-edges in ๐บ with respect to the tree ๐
- B.
There are no cross-edges in ๐บ with respect to the tree ๐
- C.
There are no forward-edges in ๐บ with respect to the tree ๐
- 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.