Papers
Topics
Authors
Recent
Search
2000 character limit reached

Disjoint-set Tree

Updated 31 January 2026
  • Disjoint-set trees are data structures that facilitate efficient union and find operations by maintaining nodes, ranks, and parent relationships with rank-monotonicity.
  • They implement dynamic connectivity via union-by-rank, path compression, and push operations that transform trees into recognizable union trees.
  • The NP-completeness of recognizing union-find trees underscores the deep combinatorial challenges and impacts certification of efficient disjoint-set algorithms.

A disjoint-set tree is a data structure central to the implementation of dynamic connectivity algorithms, supporting efficient union and find operations on a collection of disjoint sets. In the context of disjoint-set forests, the most prevalent realizations are Union-Find trees that employ merging heuristics such as union-by-rank and perform path compression to improve amortized time complexity. The precise structural characterization and computational complexity of recognizing such trees, especially under union-by-rank with path-compression, involve deep combinatorial and complexity-theoretic insights (Gelle et al., 2017).

1. Formal Definition of Ranked and Union-Find Trees

A ranked tree is defined as the quadruple

t=(Vt,roott,rankt,parentt)t = (V_t, \mathsf{root}_t, \mathsf{rank}_t, \mathsf{parent}_t)

where

  • VtV_t is a finite set of nodes,
  • roott∈Vt\mathsf{root}_t \in V_t is the root node,
  • rankt:Vt→{0,1,2,… }\mathsf{rank}_t: V_t \rightarrow \{0,1,2,\dots\} maps each node to a nonnegative integer rank,
  • parentt:Vt∖{roott}→Vt\mathsf{parent}_t: V_t \setminus \{\mathsf{root}_t\} \rightarrow V_t gives each non-root node its parent.

The tree must satisfy the rank-monotonicity condition:

rankt(x)<rankt(parentt(x)),for every x≠roott.\mathsf{rank}_t(x) < \mathsf{rank}_t(\mathsf{parent}_t(x)), \quad \text{for every } x \neq \mathsf{root}_t.

Two operations are fundamental:

  • Merge (union-by-rank): When merging disjoint trees tt and ss with rank(t)≥rank(s)\mathsf{rank}(t) \geq \mathsf{rank}(s), the root of ss becomes a child of the root of VtV_t0. If VtV_t1, the new root's rank is incremented by one.
  • Path compression (collapse): For a tree VtV_t2 and a node VtV_t3, VtV_t4 reattaches all ancestors of VtV_t5 (higher in the tree) directly under the root, without modifying ranks.

A Union tree is any ranked tree built from singleton rank-0 trees by repeated merges. Equivalently, VtV_t6 is a Union tree if every node VtV_t7 has exactly one child for each rank in VtV_t8.

A Union-Find tree is the closure (from singletons) under merges and collapses. This combination models the standard practice for efficiency in disjoint-set data structures (Gelle et al., 2017).

2. Structural Characterization Using "Push" Operations

To structurally characterize which ranked trees are Union-Find trees (i.e., can result from merges and path-compressions), the "push" operation is introduced. Let VtV_t9 be a ranked tree, and roott∈Vt\mathsf{root}_t \in V_t0 be siblings under the same parent with roott∈Vt\mathsf{root}_t \in V_t1. The push roott∈Vt\mathsf{root}_t \in V_t2 modifies roott∈Vt\mathsf{root}_t \in V_t3 so that roott∈Vt\mathsf{root}_t \in V_t4 becomes a child of roott∈Vt\mathsf{root}_t \in V_t5, with all other parent/rank data unchanged.

Formally, the push relation roott∈Vt\mathsf{root}_t \in V_t6 denotes a single such operation, and roott∈Vt\mathsf{root}_t \in V_t7 its reflexive-transitive closure.

Structural equivalence theorem (Theorem 3):

A ranked tree roott∈Vt\mathsf{root}_t \in V_t8 is a Union-Find tree if and only if

roott∈Vt\mathsf{root}_t \in V_t9

for some Union tree rankt:Vt→{0,1,2,… }\mathsf{rank}_t: V_t \rightarrow \{0,1,2,\dots\}0 on the same nodes, root, and rank function. Thus, any Union-Find tree can be transformed into a Union tree through a sequence of "pushes," capturing the effect of path-compression but on the tree shape only (Gelle et al., 2017).

3. Complexity of Recognizing Union-Find Trees

The decision problem UNION-FIND-TREE is defined as: Given a ranked tree rankt:Vt→{0,1,2,… }\mathsf{rank}_t: V_t \rightarrow \{0,1,2,\dots\}1 satisfying rank-monotonicity, is rankt:Vt→{0,1,2,… }\mathsf{rank}_t: V_t \rightarrow \{0,1,2,\dots\}2 a Union-Find tree under the union-by-rank and path-compression strategy?

Recognition is shown to be NP-complete.

NP-hardness (Sketch):

A reduction from the strongly NP-complete PARTITION problem constructs a "flat tree" whose structure encodes the partition constraints:

  • Immediate children of the root include
    1. a gadget of three subtrees of ranks 0, 1, 2,
    2. rankt:Vt→{0,1,2,… }\mathsf{rank}_t: V_t \rightarrow \{0,1,2,\dots\}3 "apples" of weight rankt:Vt→{0,1,2,… }\mathsf{rank}_t: V_t \rightarrow \{0,1,2,\dots\}4: subtrees of rank 2 with rankt:Vt→{0,1,2,… }\mathsf{rank}_t: V_t \rightarrow \{0,1,2,\dots\}5 children of rank 1 and one child of rank 0,
    3. rankt:Vt→{0,1,2,… }\mathsf{rank}_t: V_t \rightarrow \{0,1,2,\dots\}6 "baskets": subtrees of rank 3 with rankt:Vt→{0,1,2,… }\mathsf{rank}_t: V_t \rightarrow \{0,1,2,\dots\}7 children of rank 0 and a single special child of rank 1 (with its own rank 0 child).

Via the push operation, a successful transformation into a Union tree corresponds precisely to solving the PARTITION instance.

A key lemma (Proposition 7): in every Union-Find tree rankt:Vt→{0,1,2,… }\mathsf{rank}_t: V_t \rightarrow \{0,1,2,\dots\}8,

rankt:Vt→{0,1,2,… }\mathsf{rank}_t: V_t \rightarrow \{0,1,2,\dots\}9

which enforces the combinatorics of the packing (Gelle et al., 2017).

Membership in NP:

Given the push characterization, a nondeterministic guess of at most parentt:Vt∖{roott}→Vt\mathsf{parent}_t: V_t \setminus \{\mathsf{root}_t\} \rightarrow V_t0 pushes (where parentt:Vt∖{roott}→Vt\mathsf{parent}_t: V_t \setminus \{\mathsf{root}_t\} \rightarrow V_t1) suffices; checking each push and final verification of the Union tree property is polynomial time. Thus the problem lies in NP.

Theorem: Recognizing whether a given ranked tree is a Union-Find tree under union-by-rank is NP-complete (Gelle et al., 2017).

4. Verification, Certification, and Further Complexity

A consequence of this hardness is that any run-time certifier that checks whether a given forest structure is valid under arbitrary merges and path compressions must, in the worst case, solve an NP-complete problem. Thus, fully automatic certification of arbitrary union-find implementations, under union-by-rank with path-compression, cannot be both general and polynomial-time (Gelle et al., 2017).

Additionally, an open question is whether there exists a different merging heuristic (other than union-by-rank or union-by-size) that preserves the optimal parentt:Vt∖{roott}→Vt\mathsf{parent}_t: V_t \setminus \{\mathsf{root}_t\} \rightarrow V_t2 amortized complexity while admitting polynomial-time recognition.

Another open problem concerns the rank-unlabeled case: the complexity of recognition when only the tree structure (not node ranks) is given, i.e., whether there exists a rank assignment making the tree derivable as a union-by-rank Union-Find tree.

5. Mathematical Consequences and Structural Richness

These findings establish that the combinatorial structure of all possible Union-Find forests with path compression is substantially more complex than that of Union trees (without path compression), the latter being well-understood. The richness of Union-Find trees arises from path-compression modifying ancestor-descendant relationships by creating complex dependencies among subtrees that cannot be decoded into a simple local condition (in contrast with the case without path-compression).

This result highlights the intersection of fine-grained data-structure analysis, complexity theory, and formal certification, suggesting ongoing research at the boundary of structural combinatorics and efficient algorithmic verification (Gelle et al., 2017).

6. Summary Table: Classes of Disjoint-Set Trees

Tree Class Operations Allowed Recognition Complexity
Union Trees Merge (union-by-rank/size), no path compression Local, polynomial-time
Union-Find Trees Merge (union-by-rank/size), path compression NP-complete

Union trees permit a structural local characterization, but the addition of path compression renders the recognition globally constrained and NP-complete (Gelle et al., 2017).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Disjoint-set Tree.