Mental Model
Path compression makes finding the leader of a group faster by making every node on the path point directly to the leader.
Analogy: Imagine a family tree where each person points to their parent. Path compression is like updating everyone in the family line to point directly to the oldest ancestor, so you can find the root ancestor quickly next time.
Before path compression: 4 -> 3 -> 1 -> 1 ā find(4) starts here After path compression: 4 -> 1 3 -> 1 1 -> 1
