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?
- A. O(V^3)
- B. O(E log E) even when sorted
- C. O(E alpha(V))
- 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
- Problem: What does the Kuhn-Munkres (Hungarian) algorithm compute on a bipartite graph with weights?
- Problem: Which approach computes the number of distinct substrings of a string of length n in O(n log n) with a suffix array?
- Problem: Which graph algorithm checks whether a directed graph is a DAG in O(V + E)?
- Problem: What is the expected number of comparisons for a binary search on a sorted array of n = 1000 elements (successful search, worst…
- Problem: What is the time complexity of finding the articulation points and bridges together with one DFS?
- Problem: How many pairs (i < j) of integers in [1, 30] have i + j divisible by 6? Run the code. python print(sum(1 for i in range(1, 31)…