Ranked path compression

Home > Computer Science > Algorithms and data structures > Disjoint Set Union > Ranked path compression

In this implementation, we combine the path compression and union by rank techniques. In addition to compressing paths, we also update the rank of each set during path compression. The time complexity of this implementation is O(alpha(n)).