Skip to content

Disjoint-Set Data Structure

Maintain a mutable partition under Make-Set, Find, and Union, typically with representative-rooted forests, union by rank or size, and path compression for inverse-Ackermann amortized time.

Version
v2 · 2026-09-06 · History
Domain-specific #
1691
Origin domain
computer science
Subdomain
data structures
Aliases
Union–find, Union-find data structure, Merge–find set, Disjoint-set union, DSU

Core Idea

A disjoint-set data structure maintains a partition of elements into pairwise-disjoint sets. Make-Set(x) creates a singleton, Find(x) returns a representative of the unique block containing \(x\), and Union(x,y) merges the two blocks when distinct. The standard disjoint-set forest represents each block as a rooted tree; union by rank/size limits height and path compression rewires search paths toward the root.

The recognition invariant is mutable partition + stable representative equivalence test + union-only coarsening + forest heuristics + amortized efficiency.

Scope of Application

Union–find supports Kruskal’s minimum-spanning-tree algorithm, incremental graph connectivity, connected-component labeling, equivalence-class computation, unification-like tasks, image processing, percolation simulation, and offline least-common-ancestor algorithms.

It excels when the required relation only coarsens. If connectivity edges are deleted or equivalence decisions must be undone, another structure or explicit rollback/persistence scheme is needed.

Clarity

Representatives are identifiers, not necessarily canonical semantic elements. Different union orders and heuristics can select different roots while representing the same partition. Correctness depends on equivalence classes, not on one particular forest shape.

The inverse-Ackermann bound is amortized over a sequence, not a worst-case constant guarantee for each individual operation. Its practical smallness does not make the mathematical distinction disappear.

Manages Complexity

The structure avoids storing each block as a repeatedly copied set. It maintains enough indirection to answer same-block queries and merge blocks cheaply. Path compression invests work during Find to accelerate later operations; rank/size prevents pathological growth during Union.

Abstract Reasoning

  1. Initialize every element as a singleton.
  2. Maintain one parent pointer per forest node.
  3. Follow parents to locate a representative.
  4. Compress the traversed path without changing membership.
  5. Before union, find both roots.
  6. If different, link the lower-rank/smaller tree under the other and update metadata.
  7. Prove that every element has one root and blocks remain disjoint.
  8. Analyze sequences amortized, not operations in isolation.
  9. Reject the classic structure when splits or deletions are required.

Knowledge Transfer

The portable structure is representing an evolving equivalence relation by delegated representatives and cheap irreversible merges. The proposed immediate parent is Data Structure.

Relationships to Other Abstractions

Local relationship map for Disjoint-Set Data StructureParents appear above the current abstraction, mutual partners to the right, and children below. Node labels state whether each abstraction is prime or domain-specific; colors identify relation types.Disjoint-SetData StructureDOMAINPrime abstraction: Data Structure — is a kind ofData StructurePRIME

Current abstraction Disjoint-Set Data Structure Domain-specific

Parents (1) — more general patterns this builds on

  • Disjoint-Set Data Structure is a kind of Data Structure Prime

    Data Structure is the proposed immediate parent.

Hierarchy path (1) — routes to 1 parentless root

Neighborhood in Abstraction Space

Disjoint-Set Data Structure sits in a sparse region of the domain-specific corpus (83rd percentile for distinctiveness): few abstractions share its structure, so a faithful description tends to retrieve it precisely.

Family — Discrete Structures & Graph Algorithms (17 abstractions)

Nearest neighbors

Computed from structural-signature embeddings · 2026-09-08