GATE / CS ARCHIVE

GATE CSE 2020 / QUESTION 31

GATE CSE 2020 Q31

Algorithms · Graph Algorithms · Full GATE CSE 2020 paper

GATE 2020, Q31 2 marks · MCQ
Report issue

Graph Algorithms

Question 31, GATE 2020: A weighted undirected graph has MST T maintained in adjacency lists. A new weighted edge (u,v) is added. Without an additional preprocessed path-query index, what is the worst-case time to decide whether T remains an MST? A Θ(|E|+|V|); B Θ(|E||V|); C Θ(|E| log |V|); D Θ(|V|).
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Worked explanation

Let e be the new edge and P the unique u-v path in T. If w(e)<max weight on P, replace a maximum-weight path edge by e; the resulting spanning tree is strictly lighter, so T fails. Conversely, if w(e)≥that maximum, consider any competing tree using e. Removing e separates it into two parts; P crosses that cut at some tree edge f with w(f)≤w(e). Replacing e by f gives an old-graph spanning tree no heavier than the competitor. Since T was minimum among old trees, no new competitor is lighter. A DFS of T visits at most |V|−1 edges, carrying the path maximum. No need to rerun an MST algorithm on all of G.

Derivation and answer

Adding edge(u, v) creates one cycle with the unique u-v path in T. T remains minimum exactly when the new weight is at least the maximum weight on that tree path. A DFS of the adjacency-list tree finds the path and its maximum in O(|V|), and an unpreprocessed path-like tree can force inspection ofΘ(|V|) edges. ThusΘ(|V|), D.

Original paper, page 10 · Answer key