GATE / CS ARCHIVE

GATE CSE 1992 / QUESTION 1(ix)

Kruskal when edges are already sorted

Algorithms · Graph Algorithms · Full GATE CSE 1992 paper

GATE 1992, Q1(ix) Other
Report issue

Graph Algorithms

Question 1(ix), GATE 1992: For n vertices and m presorted edges, state Kruskal’s running time and the union-find model.
Question 1(ix), GATE 1992: For n vertices and m presorted edges, state Kruskal’s running time and the union-find model.
Tap to enlarge
Answer & solution

Answer: O(m α(n)+n) with optimized union-find; O(m log n+n) with balanced-tree bounds (no official key was published)

Initialize n singleton components, scan edges in the given order and use two find operations to test whether each edge crosses components. Accepted edges trigger a union, at most n−1 times. With path compression and union by rank, the total is O(m α(n)+n), since sorting has already been removed. A simpler union-find implementation with logarithmic operations gives O(m log n+n). Reporting only the usual O(m log m) sorting bound would ignore the supplied sorted order. The exact implementation must be stated rather than treating one data-structure bound as universal.

Original paper, page 1