Disjoint-set data structure: Difference between revisions

Content deleted Content added
No edit summary
m ce
Line 15:
In [[computer science]], a '''disjoint-set data structure''', also called a '''union–find data structure''' or '''merge–find set''', is a [[data structure]] that stores a collection of [[Disjoint sets|disjoint]] (non-overlapping) [[Set (mathematics)|sets]]. Equivalently, it stores a [[partition of a set]] into disjoint [[subset]]s. It provides operations for adding new sets, merging sets (replacing them with their [[Union (set theory)|union]]), and finding a representative member of a set. The last operation makes it possible to determine efficiently whether any two elements belong to the same set or to different sets.
 
While there are several ways of implementing disjoint-set data structures, in practice they are often identified with a particular implementation calledknown as a '''disjoint-set forest'''. This is a specialized type of [[Forest (graph theory)|forest]] which performs unionsunion and findsfind operations in near-constant [[Amortized analysis|amortized time]]. To performFor a sequence of {{mvar|m}} addition, union, or find operations on a disjoint-set forest with {{mvar|n}} nodes, requiresthe total time required is {{math|[[Big O notation|''O'']](''m''α(''n''))}}, where {{math|α(''n'')}} is the extremely slow-growing [[inverse Ackermann function]]. Although Disjointdisjoint-set forests do not guarantee this performancetime onper a per-operation basis. Individual union and find operations can take longer than a constant times {{math|α(''n'')}} time, but each operation causesrebalances the disjoint-set forest to adjust itselfstructure so that successivesubsequent operations arebecome faster. As Disjointa result, disjoint-set forests are both [[asymptotically optimal]] and practically efficient.
 
Disjoint-set data structures play a key role in [[Kruskal's algorithm]] for finding the [[minimum spanning tree]] of a graph. The importance of minimum spanning trees means that disjoint-set data structures underlie a wide variety of algorithms. In addition, disjoint-set data structures also have applications to symbolic computation, as well as in compilers, especially for [[register allocation]] problems.