Skip to content
Official PYQ · 2020

GATE CS 2020 Q31 — Minimum Spanning Trees

Explain with AI

Let  G=(V,E)G = (V, E) be a weighted undirected graph and let TT be a Minimum Spanning Tree (MST) of GG maintained using adjacency lists. Suppose a new weighed edge (u,v)∈V×V(u, v) \in V \times V is added to GG. The worst case time complexity of determining if TT is still an MST of the resultant graph is

Choose one option
View worked solution

Answer: D

To determine if the tree TT remains a Minimum Spanning Tree (MST) after adding a new weighted edge e=(u,v)e = (u, v) with weight w(e)w(e), we can use the Cycle Property of MSTs.

1. Theoretical Background

When a new edge e=(u,v)e = (u, v) is added to the tree TT, it creates a unique cycle CC consisting of the edge ee and the unique path between uu and vv in TT.

  • According to the cycle property, TT remains an MST of the new graph if and only if the newly added edge ee has the maximum weight in this cycle CC.
  • In other words, TT is still an MST if and only if: w(e)≥max⁡{w(e′)∣e′ is an edge on the path between u and v in T}w(e) \ge \max \{ w(e') \mid e' \text{ is an edge on the path between } u \text{ and } v \text{ in } T \}

2. Algorithm and Time Complexity

To verify this condition, we perform the following steps:

  1. Find the unique path between vertices uu and vv in the tree TT using a standard graph traversal algorithm like Depth-First Search (DFS) or Breadth-First Search (BFS) starting from uu.
  2. During the traversal, keep track of the maximum edge weight encountered on the path to vv. Let this maximum weight be wmax⁡w_{\max}.
  3. Compare the weight of the new edge, w(e)w(e), with wmax⁡w_{\max}. If w(e)≥wmax⁡w(e) \ge w_{\max}, then TT remains an MST; otherwise, it does not.

Since TT is a tree, it contains exactly ∣V∣|V| vertices and ∣V∣−1|V| - 1 edges. Running DFS or BFS on a tree represented by adjacency lists takes time proportional to the number of vertices and edges in the tree:

Θ(∣V∣+∣ET∣)=Θ(∣V∣+∣V∣−1)=Θ(∣V∣)\Theta(|V| + |E_T|) = \Theta(|V| + |V| - 1) = \Theta(|V|)

Thus, the worst-case time complexity of determining if TT is still an MST is Θ(∣V∣)\Theta(|V|).

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

Published
Report a correction
Keep exploringMore Minimum Spanning Trees questions