コンテンツにスキップ

DSWアルゴリズム

出典: フリー百科事典『ウィキペディア(Wikipedia)』

DSW (Day-Stout-Warren algorithm)  n O(log n) 1976  Colin Day [1]1986  CACM  Quentin F. Stout  Bette Warren [2]

 (O(n)) In-placeDay 2 (in-order) 2[3]

Stout-Warren [2]Day-Stout-Warren 212 Day [2][3]

Timothy J. Rolfe  2002 DSW [3]Adam Drozdek  "6.7.1: The DSW Algorithm" [4]Rolfe 2調 (self-adjusting tree) 

[]


Stout-Warren DSW[2][note 1]31

(一)

(二) tree-to-vine 

(三)() vine-to-tree 

(四)

(五)

[note 2]
routine tree-to-vine(root)
    // Convert tree to a "vine", i.e., a sorted linked list,
    // using the right pointers to point to the next node in the list
    tail ← root
    rest ← tail.right
    while rest ≠ nil
        if rest.left = nil
            tail ← rest
            rest ← rest.right
        else
            temp ← rest.left
            rest.left ← temp.right
            temp.right ← rest
            rest ← temp
            tail.right ← temp
routine vine-to-tree(root, size)
    leaves ← size + 1 − 2⌊log2(size + 1))⌋
    compress(root, leaves)
    size ← size − leaves
    while size > 1
        compress(root, ⌊size / 2⌋)
        size ← ⌊size / 2⌋
routine compress(root, count)
    scanner ← root
    for i ← 1 to count
        child ← scanner.right
        scanner.right ← child.right
        scanner ← scanner.right
        child.right ← scanner.left
        scanner.left ← child

注釈[編集]



(一)^ Stout  Warren compress 

(二)^ tree-to-vine 

参考文献[編集]

  1. ^ Day, A. Colin (1976). “Balancing a Binary Tree”. Comput. J. 19 (4): 360–361. doi:10.1093/comjnl/19.4.360. 
  2. ^ a b c d Stout, Quentin F.; Warren, Bette L. (September 1986). “Tree rebalancing in optimal space and time”. CACM 29 (9): 902–908. doi:10.1145/6592.6599. http://www.eecs.umich.edu/~qstout/pap/CACM86.pdf. 
  3. ^ a b c Rolfe, Timothy J. (December 2002). “One-Time Binary Search Tree Balancing: The Day/Stout/Warren (DSW) Algorithm”. SIGCSE Bulletin (ACM SIGCSE) 34 (4): 85–88. doi:10.1145/820127.820173. オリジナルの13 Dec 2012時点におけるアーカイブ。. https://archive.fo/cZOP. 
  4. ^ Drozdek, Adam (1996). Data Structures and Algorithms in C++. PWS Publishing Co.. pp. 173–175. ISBN 0-534-94974-6