Skip to main content

GATE CSE 2025Algorithms › Graph AlgorithmsVerified

GATE CSE 2025 PYQ: Let G ( V , E ) G(V, E) G ( V , E ) be an undirected and unweighted graph with 100 100 100 vertices. Let d (…

Let G(V,E)G(V, E) be an undirected and unweighted graph with 100 vertices. Let d(u,v)d(u, v) denote the number of edges in a shortest path between vertices uu and vv in VV. Let the maximum value of d(u,v),u,v∈Vd(u, v), u, v \in V such that u≠vu \neq v, be 30. Let TT be any breadth-first-search tree of GG. Which ONE of the given options is CORRECT for every such graph GG ?

  1. A
    The height of TT is exactly 15.
  2. B
    The height of TT is exactly 30.
  3. C
    The height of TT is at least 15.
    Correct answer
  4. D
    The height of TT is at least 30.

Answer

(C) The height of T T T is at least 15 15 15 .

Approach

The condition says the graph has diameter 30: there exist vertices u,v with d(u,v)=30. For any BFS root r, the height of the BFS tree is the maximum distance from r to any vertex, i.e. the eccentricity of r. Using the triangle inequality, 30 = d(u,v) ≤ d(r,u)+d(r,v), so at least one of u or v is at distance at least 15 from r. Hence every BFS tree has height at least 15, and this bound is tight when the root is chosen midway between a diametral pair.

For every graph with diameter 30, any BFS tree rooted at any vertex has height at least ceil(30/2)=15, because a diametral pair cannot both be closer than 15 to the root. The height can be 15 or 30 depending on the root, so only 'at least 15' is correct.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.