Data Structures & AlgorithmsVery hardICPC regional · MST

Problem: What is the complexity of Kruskal's algorithm when edges are already sorted and union-find uses path compression and union by rank?

  1. A. O(V^3)
  2. B. O(E log E) even when sorted
  3. C. O(E alpha(V))
  4. D. O(V^2)

Correct answer: C. O(E alpha(V))

With sorting free, each union-find operation costs amortised O(alpha(V)), so the algorithm is O(E alpha(V)).

More Coding Interview Problems questions

Exams that ask this topic