We analyze each option separately:
Option A: DFS on a directed graph with n vertices and n edges is guaranteed to find at least one back edge.
- Analysis:
In directed graphs, a back edge is one that goes from a vertex to one of its ancestors in the DFS tree, indicating the presence of a cycle. However, it is possible to have a directed acyclic graph (DAG) with nn vertices and nn edges. For example, for n=3n=3, consider the graph with edges: 1→2,1→3,2→3.1 \to 2,\quad 1 \to 3,\quad 2 \to 3. This graph has 3 vertices and 3 edges and is acyclic. In a DFS of this DAG, no back edge will be found because there is no cycle. - Conclusion: False.
Option B: DFS on an undirected graph with n vertices and n edges is guaranteed to find at least one back edge.
- Analysis:
In undirected graphs, a DFS classifies every edge that is not a tree edge as a back edge (since every non-tree edge connects a vertex to an already discovered vertex that is not its parent). For a connected undirected graph, a tree (spanning tree) has n−1n-1 edges. Thus, if there are nn edges, there is exactly one extra edge, which creates a cycle. In every cycle in an undirected graph, DFS will encounter a non-tree edge that connects a vertex to an ancestor, classifying it as a back edge. Even if the graph is disconnected, each connected component with a cycle (which must occur because the overall edge count forces at least one component to have a cycle) will yield a back edge during DFS. - Conclusion: True.
Option C: DFS on an undirected graph with n vertices and n edges may find a cross edge.
- Analysis:
In undirected graphs, the DFS edge classifications are limited to tree edges and back edges. There is no concept of a cross edge in an undirected DFS because any edge between two vertices that are not in a parent-child relationship will necessarily be a back edge. - Conclusion: False.
Option D: DFS on a directed graph with n vertices and n edges may find one cross edge.
- Analysis:
In directed graphs, the DFS can classify edges into tree, forward, back, and cross edges. A cross edge is one that connects vertices in different DFS subtrees (or, more precisely, an edge that is neither a tree edge, a forward edge, nor a back edge). It is possible for a directed graph with nn vertices and nn edges to be structured in such a way that, depending on the DFS order, a cross edge is discovered. For instance, consider a DAG (which has no back edges) where an edge goes from a vertex in one DFS tree to a vertex in another. A concrete example for n=3n=3 is: 1→2,3→2,1→3.1 \to 2,\quad 3 \to 2,\quad 1 \to 3. If DFS starts at 1, it might traverse to 2 and finish, and then later start at 3; when processing the edge 3→23 \to 2, since 2 is already finished, it can be classified as a cross edge. - Conclusion: True.
Final Answer:
- A: False
- B: True
- C: False
- D: True
Thus, the correct options are B and D.
Source: ChatGPT