🎉 October Learning Month — learn a new software term every day!
An interactive flashcard trainer for software engineering terms.

Union Find

In plain terms

The algorithm behind disjoint sets for merging and querying groups.

Going deeper

Union-find supports two operations: union (merge two groups) and find (which group is this in?), made fast with optimizations. It elegantly solves connectivity questions.

Under the hood

Path compression flattens trees and union by rank keeps them shallow, yielding nearly O(1) amortized operations.

Examples

Kruskal's algorithm, percolation, friend circles, dynamic connectivity.

Think of it like...

Like tracing everyone back to their family head to see if two people are related.

Feedback & Bug Report