IAE Academy

GATE 2025 CS1 Q.18: solution and answer

GATE 2025 · CS1Q.18 · 1 mark · MCQ

Let be any undirected graph with positive edge weights, and be a minimum spanning tree of . For any two vertices, and , let and be the shortest distances between and in and , respectively. Which ONE of the options is CORRECT for all possible , , and ?

  1. (A)

  2. (B)

  3. (C)

  4. (D)

See the question in the paper

Answer and solution

ANSWER

holds for all possible , , and , so option (B) is correct.

Official answer: BSource: Official answer key, GATE 2025 CS1 (IIT Roorkee)

  1. is a spanning tree of , so every edge of is an edge of with the same weight — is a subgraph of on the same vertex set.

  2. Any path between and that lies entirely in therefore also exists in , using the same edges and hence the same total weight.

  3. So the set of all - paths available in is a superset of the set of all - paths available in (every -path is also a -path, and may additionally have paths that use non-tree edges).

  4. is the minimum weight over the (smaller) set of -paths; is the minimum weight over the (larger or equal) set of -paths.

  5. Minimizing a quantity over a superset of candidates can never give a larger value than minimizing over a subset of those candidates, since every candidate available to the subset is also available to the superset: .

  6. This holds for every choice of , , , — including cases where are adjacent in or where itself is a tree, in which equality happens to hold — but equality is not guaranteed in general (e.g. a shorter path in can bypass the tree route via non-tree edges), so (A) is not always true, and since always, (needed for (C) alone) and (option D) can both fail whenever equality holds.

  7. Hence the only relation guaranteed for all is : option (B).

KEY IDEA

A minimum spanning tree only removes edges from ; it never adds a shorter route. So every path available inside is also available inside , meaning shortest-path distance can only stay the same or shrink when you move from to : , always.

WATCH OUT FOR

Assuming a "minimum" spanning tree must preserve shortest-path distances (confusing MST with a shortest-path tree) and picking (A); or reasoning direction backwards and picking (C) by thinking "the tree is smaller so distances in it must be smaller."

From the GATE 2025 CS1 paper. Every question of this paper · Download the full paper · All 28 Graph algorithms questions, with notes

More Graph algorithms questions