ISRO Scientist/Engineer CSE 2020Data Structures › Not yet assigned to a topic
ISRO Scientist/Engineer CSE 2020 PYQ: $G$ is an undirected graph with vertex set $\{v1, \ v2, \ v3, \ v4, \ v5, \ v6, \ v7\}$ and edge set…
$G$ is an undirected graph with vertex set $\{v1, \ v2, \ v3, \ v4, \ v5, \ v6, \ v7\}$ and edge set $\{v1v2,\ v1v3,\ v1v4\ ,v2v4,\ v2v5,\ v3v4,\ v4v5,\ v4v6,\ v5v6,\ v6v7\ \}$. A breadth first search of the graph is performed with $v1$ as the root node. Which of the following is a tree edge?
- A$v2v4$
- B$v1v4$Correct answer
- C$v4v5$
- D$v3v4$
Answer
(B) $v1v4$
Approach
BFS starts at v1, so its unvisited neighbours v2,v3,v4 are all discovered directly from the root and placed at level 1. Thus edges v1v2, v1v3, v1v4 are always tree edges. The other options cannot be guaranteed: v2v4 and v3v4 connect two level-1 vertices, so neither can be a tree edge; v4v5 may be a tree edge only if v4 is processed before v2, but if v2 discovers v5 first then v4v5 is not a tree edge. Therefore only v1v4 is necessarily a tree edge.
Reviewed by ISRO IQ Editorial Team.