GATE CS 2024 Set 1 — Question 45
MSQ+2 / -0HardDFS Edge ClassificationGraph AlgorithmsAlgorithmsBFS TraversalGraphs (Data Structure)Programming & Data Structures
Algorithms → Graph Algorithms → BFS Traversal
Last updated
Question
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
Correct answer
(C) There are no forward-edges in G with respect to the tree T
Solution
Let be a spanning tree of rooted at . We are given that is both a DFS tree and a BFS tree.Analysis of Edge Types:
1.Forward Edges: A forward edge in a DFS tree connects a node to a descendant that is not its child. This implies that the path from to in the tree has length . Thus, in the tree , the level of is at least .
However, is also a BFS tree. A fundamental property of BFS is that for any edge in the graph , the level difference satisfies . If there were a forward edge in , it would require . This contradicts the tree structure requirement that . Therefore, no forward edges can exist.2.Back Edges: A back edge connects a node to an ancestor. For example, a simple cycle yields a tree which is both DFS and BFS, with being a back edge. Thus, statement (A) is false.
3.Cross Edges: A cross edge connects two nodes where neither is an ancestor of the other. Consider with edges . If we visit 3 then 2 in DFS, the tree is edges . The edge is a cross edge (from 2 to the already visited 3). This same tree is a valid BFS tree (levels: 1 at 0; 2, 3 at 1). Thus, statement (B) is false.
4.Only Tree Edges: Since back and cross edges can exist, statement (D) is false.
Conclusion: Only statement (C) is always true.More questions on Graph Algorithms
2024 Set 2 Q13Consider the following C program. Assume parameters to a function are evaluated from right to left.…2024 Set 2 Q17Let be the adjacency matrix of a simple undirected graph . Suppose is its own inverse.…2024 Set 1 Q17Given an integer array of size , we want to check if the array is sorted (in either ascending or…2024 Set 1 Q18Consider the following C program: [code] Which one of the following statements is CORRECT?2024 Set 1 Q19Consider the following C program: [code] Assume that the input to the program from the command line…
Practice GATE CS PYQs with adaptive difficulty
Timed practice, skill tracking, and AI explanations — free to start.
Start practicing free