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 .
Suppose that the input directed graph is a directed acyclic graph (DAG).
For an edge , which of the following options will NEVER be correct?
View worked solution
Answer: B;D
To determine which options can never be correct for a directed edge in a Directed Acyclic Graph (DAG) , we analyze the relationship between the discovery interval and finishing interval of vertices and during Depth-First Search (DFS).
1. The Parenthesis Theorem
For any two vertices and in a graph, their active intervals and must satisfy exactly one of the following conditions:
- Disjoint: The intervals are entirely separate, i.e., or .
- Nested: One interval is entirely contained within the other, i.e., or .
Intervals can never partially overlap. Therefore, the relation is impossible for any pair of vertices in any graph. This makes Option D impossible.
2. Classification of Edges in a DAG
For a directed edge , the type of edge determines the interval relationship:
- Tree / Forward Edge: is an ancestor of in the DFS forest. This corresponds to the nested interval . This matches Option A, which is possible.
- Cross Edge: is visited and finished before is discovered. This corresponds to the disjoint interval . This matches Option C, which is possible.
- Back Edge: is an ancestor of in the DFS forest. This corresponds to the nested interval . However, a back edge implies a directed cycle in the graph. Since is a DAG (Directed Acyclic Graph), it cannot contain any back edges. Thus, this relation is impossible, making Option B impossible.
Conclusion
The options that can NEVER be correct are B and D.
Free practice · Your answers on this page are not saved.
