: disjoint-set data structure2便Union-Find

Find: 2使

Union: 21

2Union-FindMerge-Find MakeSet13

 (representative) Find(x)  xUnion 2

素集合連結リスト

編集



MakeSet1Union2FindΩ(n)

FindUnionΩ(n) 

Union (weighted-union heuristic) nmMakeSetUnionFind O(m + nlog n) [1]

素集合森

編集

 (disjoint-set forest) 1964Bernard A. Galler  Michael J. Fischer [2]

FindUnion21
 function MakeSet(x)
     x.parent := x
 
 function Find(x)
     if x.parent == x
        returnxelse   
        return Find(x.parent)
 
 function Union(x, y)
     xRoot := Find(x)
     yRoot := Find(y)
     xRoot.parent := yRoot

使2

 union by rank Unionrank 1 rank  0  rank r rank  r+1 MakeSetUnionFind     MakeSet  Union 
 function MakeSet(x)
     x.parent := x
     x.rank   := 0
 
 function Union(x, y)
     xRoot := Find(x)
     yRoot := Find(y)
     if xRoot.rank > yRoot.rank
         yRoot.parent := xRoot
     else if xRoot.rank < yRoot.rank
         xRoot.parent := yRoot
     else if xRoot != yRoot // x とyが同じ集合にない場合だけマージする。
         yRoot.parent := xRoot
         xRoot.rank := xRoot.rank + 1

 path compression FindFindFind  Find 
 function Find(x)
     if x.parent == x
        returnxelse
        x.parent := Find(x.parent)
        return x.parent

                5

Fredman  Saks 19891   [3]

応用

編集

2調調

Boost Graph Library Incremental Connected Components 使使

2[4]

歴史

編集

使 O(log*n) log*  van Leeuwen  Find 

2007ACM SIGPLAN  Workshop on ML Sylvain Conchon  Jean-Christophe Filliâtre Coq使[5]

脚注・出典

編集
  1. ^ Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction to Algorithms, Second Edition. MIT Press and McGraw-Hill, 2001. ISBN 0-262-03293-7. Chapter 21: Data structures for Disjoint Sets, pp.498–524.
  2. ^ Bernard A. Galler and Michael J. Fischer. An improved equivalence algorithm. Communications of the ACM, Volume 7, Issue 5 (May 1964), pages 301-303. 素集合森に関する最初の論文。 ACM Digital Library
  3. ^ M. Fredman and M. Saks. The cell probe complexity of dynamic data structures. Proceedings of the Twenty-First Annual ACM Symposium on Theory of Computing, pages 345–354. May 1989. "Theorem 5: Any CPROBE(log n) implementation of the set union problem requires Ω(m α(m, n)) time to execute m Find's and n−1 Union's, beginning with n singleton sets."
  4. ^ Zvi Galil and Giuseppe F. Italiano. Data structures and algorithms for disjoint set union problems, ACM Computing Surveys, Volume 23, Issue 3 (September 1991), pages 319-344. ACM Digital Library
  5. ^ Sylvain Conchon and Jean-Christophe Filliâtre. A Persistent Union-Find Data Structure. In ACM SIGPLAN Workshop on ML, Freiburg, Germany, October 2007.

外部リンク

編集