Skip to content
Official PYQ · 2025

GATE CS 2025 Set 1 Q33 — Shortest Paths (Dijkstra, Bellman-Ford)

Explain with AI

Let G(V,E)G(V, E) be an undirected and unweighted graph with 100100 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 3030. Let TT be any breadth-first-search tree of GG. Which ONE of the given options is CORRECT for every such graph GG ?

Choose one option
View worked solution

Answer: C

The maximum shortest path distance between any two vertices in the graph GG is defined as the diameter of the graph. Here, the diameter is:

D=max⁡u,v∈Vd(u,v)=30D = \max_{u, v \in V} d(u, v) = 30

Let x,y∈Vx, y \in V be two vertices such that the shortest path distance between them is exactly 3030, i.e., d(x,y)=30d(x, y) = 30.

Let TT be a Breadth-First Search (BFS) tree of GG rooted at an arbitrary vertex r∈Vr \in V. The height hh of the BFS tree TT is the maximum distance from the root rr to any other vertex in the graph:

h=max⁡v∈Vd(r,v)h = \max_{v \in V} d(r, v)

By the triangle inequality of shortest path distances, we have:

d(x,y)≤d(x,r)+d(r,y)d(x, y) \le d(x, r) + d(r, y)

Since d(r,x)≤hd(r, x) \le h and d(r,y)≤hd(r, y) \le h, we can substitute these into the inequality:

30≤h+h  ⟹  2h≥30  ⟹  h≥1530 \le h + h \implies 2h \ge 30 \implies h \ge 15

Thus, the height of any BFS tree TT must be at least 1515.


Evaluating the Options:

  • Option A & B: If we construct GG as a simple path of length 3030 (with other vertices connected such that they do not increase the diameter):
    • Choosing the root rr at the center of this path yields a BFS tree of height 1515. This disproves Option B.
    • Choosing the root rr at one of the endpoints of the path yields a BFS tree of height 3030. This disproves Option A.
  • Option D: As shown above, a BFS tree rooted at the center of the path has a height of 1515, which is strictly less than 3030. This disproves Option D.
  • Option C: Since h≥15h \ge 15 holds universally for any choice of root rr, the height of TT is always at least 1515.

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

Published
Report a correction
Keep exploringMore Shortest Paths (Dijkstra, Bellman-Ford) questions