GATE / CS ARCHIVE

GATE CSE 2025 SET 1 / QUESTION 43

Bounding the height of every BFS tree

Algorithms · Graph Algorithms · Full GATE CSE 2025 Set 1 paper

GATE 2025 Set 1, Q43 2 marks · MCQ
Report issue

Graph Algorithms

Question 43, GATE 2025: An undirected unweighted graph has 100 vertices and maximum finite shortest-path distance 30 between vertices, in the usual connected-graph interpretation. T is any BFS tree. Which holds universally? A height exactly 15; B height exactly 30; C height at least 15; D height at least 30.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Approach: A BFS tree preserves distance from its root; relate those root distances to two diameter endpoints.
Let r be the BFS root and let h=maxv d(r,v), the tree height. Choose u,v with d(u,v)=30. A route from u to r and then from r to v has length d(u,r)+d(r,v), so the shortest u-to-v path obeys 30≤d(u,r)+d(r,v)≤h+h=2h. Therefore h≥15, giving C.
Also h≤30 because no pair of vertices is farther apart than the diameter. The actual height depends on the chosen root, so neither exact value in A or B is guaranteed. A path of length 30 rooted at its centre has height 15, while rooting at an endpoint gives height 30. To meet the 100-vertex requirement, attach 69 extra leaves at the central vertex; the diameter remains 30 and the same two heights remain possible.
Thus D’s stronger lower bound 30 is false. BFS preserves root distances, but it does not necessarily choose a central root.

Original paper, page 43 · Answer key