Skip to content
Official PYQ · 2025

GATE CS 2025 Set 2 Q49 — Graph Traversals (BFS, DFS)

Explain with AI

Consider the following algorithm someAlgo that takes an undirected graph GG as input.                                                                                                                  someAlgo (G)

  1. Let vv be any vertex in GG. Run BFS on GG starting at vv. Let uu be a vertex in GG at maximum distance from vv as given by the BFS.
  2. Run BFS on GG again with uu as the starting vertex. Let zz be the vertex at maximum distance from uu as given by the BFS.
  3. Output the distance between uu and zz in GG.

The output of someAlgo ( TT ) for the tree shown in the given figure is ___________. (Answer in integer)

View answer

Answer: 6:6

Worked explanation not available yet.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Graph Traversals (BFS, DFS) questions