Question
Let be a simple undirected graph. Let be a depth first search tree of . Let be a breadth first search tree of . Consider the following statements.
(I) No edge of is a cross edge with respect to . (A cross edge in is between two nodes neither of which is an ancestor of the other in .)
(II) For every edge of , if is at depth and is at depth in , then .
Which of the statements above must necessarily be true?
Official answer and solution
- Official answer
- A
- From
- Official GATE 2018 answer key
Solution
Review structural properties of edge types in DFS and BFS trees of undirected graphs.
Analyze Statement I:
- In a DFS traversal of an undirected graph, every edge of is either a tree edge (part of the DFS tree) or a back edge (connecting a vertex to an ancestor in the DFS tree).
- There are no cross edges (edges between subtrees with no ancestor-descendant relationship) in an undirected DFS tree.
- Thus, statement I is necessarily true.
Analyze Statement II:
- In a BFS traversal of an undirected graph, an edge can connect vertices at depths and where .
- Specifically, an edge may exist between two vertices at the same depth, in which case and (for example, in a triangle graph , two non-root vertices are both at depth 1 and connected by an edge).
- Since can be 0, it is not necessarily equal to 1. Statement II is false.
Therefore, only statement I must necessarily be true, matching option A.
A
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2018 Computer Science and Information Technology (CS)
- Question
- 40 of 65, printed as CS Q.30
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.