Find Operation
Determines the representative (root) of the set containing an element. Includes path compression for O(1) amortized lookup.
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
Efficiently manage a collection of disjoint sets. DSU supports Union (merging two sets) and Find (identifying which set an element belongs to).
Determines the representative (root) of the set containing an element. Includes path compression for O(1) amortized lookup.
Merges two sets by making one root point to the other. Uses rank or size to keep the trees balanced.
As we find the root, we update every node on the path to point directly to the root, significantly flattening the tree structure.
Crucial for Kruskal's MST algorithm, cycle detection in undirected graphs, and dynamic connectivity problems.