GATE / CS ARCHIVE

GATE CSE 2025 SET 2 / QUESTION 37

GATE CSE 2025 Set 2 Q37

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

GATE 2025 Set 2, Q37 2 marks · MCQ
Report issue

Graph Algorithms

Question 37, GATE 2025: In an undirected graph with positive edge weights, add the same positive constant α to every edge. How are minimum spanning trees (MSTs) and shortest paths (SPs) affected?
A. Every MST and every SP remain optimal.
B. MSTs may change; every SP remains optimal.
C. Every MST remains optimal; SPs may change.
D. Both MSTs and SPs may change.
Consider components where the corresponding spanning tree/path exists.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

For a graph with n vertices, every spanning tree uses exactly n−1 edges. Its new weight is w'(T)=w(T)+(n−1)α. Any two trees receive exactly the same increment, so their weight difference and ordering are unchanged. In particular, every old MST is still an MST, and ties between MSTs are preserved.

Paths do not all contain the same number of edges. Consider a triangle with u–w of weight 1, w–v of weight 1, and u–v of weight 3. Initially the two-edge route from u to v costs 2, beating the direct edge's 3. Add α=2 to every edge. The two-edge route now costs 3+3=6, whereas the direct edge costs 5, so the old shortest path is no longer shortest.

Thus constant addition preserves MSTs but need not preserve shortest paths: C. The distinction is a fixed edge count across all spanning trees versus a potentially variable edge count across paths. Multiplying every edge by a positive constant would preserve both, but that is a different operation.

Original paper, page 28 · Answer key