← Quiz: Union-Find (Disjoint Set Union): all 10 questions
Quiz: Union-Find (Disjoint Set Union) · Question 5 of 10
With both path compression and union by rank, the cost of one operation is:
With both path compression and union by rank, the cost of one operation is:
- A.O(n)
- B.O(log n) in the worst case for every single call
- C.O(α(n)) amortised, which is at most about 4 in practice
- D.O(1) in the worst case for every single call
Answer & explanation
Correct answer: O(α(n)) amortised, which is at most about 4 in practice
α is the inverse Ackermann function; it grows so slowly that it is effectively constant.
Can you get the rest right without peeking?
Take the timed Quiz: Union-Find (Disjoint Set Union) quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →