Rebalancing Algorithms

Data Structure AlgorithmsAnalysis of AlgorithmsAlgorithms

The rebalancing Algorithms can be performed in following way −

Day-Stout-Warren Algorithm

We can implement actually rebalance method using the Day-Stout-Warren Algorithm.It's linear in the number of nodes.

The following is a presentation of the basic DSW Algorithm in pseudo code.

  • A node is allocated called as the "pseudo-root" and make the tree's actual root as the right child of the pseudo-root.
  • Call tree-to-vine function for converting tree to sorted linked list with the pseudo-root as its argument.
  • Call vine-to-tree function for converting sorted linked list to tree again with the pseudo-root and the size (number of elements) of the tree as its argument.
  • The tree's actual root equal to the pseudo-root's right child should be built.
  • At last the pseudo-root should be disposed.

"Copy On write" Tree

If we can withstand lack of linearizability (i.e. we write a value but when we search for it immediately after it's not found; it will be then eventually found, but after 100ms-10s), a "copy on write" tree can be applied: all writes are performed by one thread (with rebalancing), and we periodically copy the tree into a read-only copy that can be implemented by reading threads without any concurrency control, we require to publish it atomically.

Concurrent Skip List

Another option is to implement a concurrent skip list: it provides logarithmic average case search/delete/insert time and is more easily parallelizable. There is a standard lock-free implementation for Java if you happen to implement it. We can obtain more information about concurrent skip lists and balanced search trees here. Particularly, we can obtain there mentions of a chromatic tree, denoted as a binary search tree that is optimized for concurrent rebalancing.

raja
Published on 03-Jan-2020 06:00:20
Advertisements