Data Structures & AlgorithmsVery hardICPC regional · data structures

Problem: Union-find with path compression and union by rank performs m operations on n elements in what amortised time per operation?

  1. A. O(alpha(n)), the inverse Ackermann function, which is at most 4 for any practical n
  2. B. O(log n), because the tree height is logarithmic
  3. C. O(1) exactly, with no amortisation needed
  4. D. O(sqrt n), from the block decomposition

Correct answer: A. O(alpha(n)), the inverse Ackermann function, which is at most 4 for any practical n

Path compression plus union by rank gives the inverse Ackermann bound. The naive version without rank can degrade to O(n) per find, and that is the trap.

More Coding Interview Problems questions

Exams that ask this topic