IAE Academy

GATE 2022 CS Q.49: solution and answer

GATE 2022 · CSQ.49 · 2 marks · MSQ

Consider a simple undirected weighted graph , all of whose edge weights are distinct. Which of the following statements about the minimum spanning trees of is/are TRUE?

  1. (A)

    The edge with the second smallest weight is always part of any minimum spanning tree of .

  2. (B)

    One or both of the edges with the third smallest and the fourth smallest weights are part of any minimum spanning tree of .

  3. (C)

    Suppose be such that and . Consider the edge with the minimum weight such that one of its vertices is in and the other in . Such an edge will always be part of any minimum spanning tree of .

  4. (D)

    can have multiple minimum spanning trees.

See the question in the paper

Answer and solution

ANSWER

The TRUE statements are (A), (B), and (C); statement (D) is FALSE — so the answer is A, B, C.

Official answer: A, B, CSource: Official answer key, GATE 2022 CS (IIT Kharagpur)

  1. Since all edge weights are distinct, Kruskal's algorithm produces the (unique) MST: at every step it either accepts the next-cheapest edge (if it joins two different components) or rejects it (if it would close a cycle), and because weights are distinct there is never a tie to break arbitrarily.

  2. (A): Let be the globally smallest edge, with endpoints ; Kruskal always accepts it, merging and into one component. When the second-smallest edge is considered, the only pair of vertices lying in the same component is itself. Since is simple, no edge other than can join and , so cannot close a cycle at this stage. Hence Kruskal always accepts : (A) is TRUE.

  3. (B): By the same argument as above, and are always both accepted. Two cases arise for the components they create. Case 1 — are vertex-disjoint: the only same-component vertex pairs are and , each already realized by or ; so (being a different edge) cannot close a cycle and is always accepted, satisfying the statement. Case 2 — share a vertex, say , , forming a 3-vertex component: among the only edge not yet placed is , and it is the unique edge whose acceptance could ever be blocked by this component (its weight rank is necessarily , since ranks 1 and 2 are already ). If , it is rejected (it would close the triangle) — but then all three possible edges among have been accounted for, so cannot lie inside this component and must be accepted. If (its rank is or the edge doesn't even exist in ), then itself cannot close this cycle and is accepted. Either way, at least one of is always accepted into the MST: (B) is TRUE.

  4. (C): This is exactly the cut property of MSTs — for any nontrivial vertex partition , the minimum-weight edge crossing the cut lies in every MST. Since all weights are distinct, adding any other crossing edge before this one is impossible without first using it (any cycle created by a heavier crossing edge could be broken by removing a heavier edge on the cycle, and the minimum crossing edge is never that heavier edge), so it is always selected by Kruskal/Prim. (C) is TRUE.

  5. (D): Distinct edge weights mean Kruskal's algorithm has no tie to break at any step, so the sequence of accept/reject decisions — and hence the MST itself — is completely determined. Therefore has exactly one MST, not multiple: (D) is FALSE.

KEY IDEA

When all edge weights in a simple graph are distinct, Kruskal's algorithm has no ties to break, so the MST is unique; this forces the 1st and 2nd smallest edges to always be in the MST (they can't yet close any cycle), forces at least one of the 3rd/4th smallest edges in, and makes the cut-property minimum-crossing-edge argument airtight.

WATCH OUT FOR

Assuming "second smallest edge is always in the MST" generalizes to "the -th smallest edge is always in the MST" for larger — it does not (that's exactly why (B) is phrased as "one or both of the 3rd and 4th smallest", not "the 3rd smallest alone"); also assuming distinct weights only give a unique MST-value rather than a unique MST itself, which would wrongly make (D) look plausible.

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

More Graph algorithms questions