Skip to main content
Log in

Efficient Reorganization of Binary Search Trees

  • Published:
Algorithmica Aims and scope Submit manuscript

Abstract.

We consider the problem of maintaining a binary search tree ({bst}) that minimizes the average access cost needed to satisfy randomly generated requests. We analyze scenarios in which the accesses are generated according to a vector of fixed probabilities which is unknown . Our approach is statistical.

We devise policies for modifying the tree structure dynamically, using rotations of accessed records. The aim is to produce good approximations of the optimal structure of the tree, while keeping the number of rotations as small as possible. The heuristics that we propose achieve a close approximation to the optimal BST, with lower organization costs than any previously studied.

We introduce the MOVE_ONCE rule. The average access cost to the tree under this rule is shown to equal the value achieved by the common rule Move to the Root (MTR). The advantage of MOVE_ONCE over MTR and similar rules is that it relocates each of the items in the tree at most once. We show that the total expected cost of modifying the tree by the MOVE_ONCE rule is bounded from above by 2(n+1)H n -4n rotations (in a tree with n records), where H n is the n th harmonic number. Extensive experiments show that this value is an overestimate, and in fact the number of rotations is linear for all the access probability vectors we tested. An approximate analysis is shown to match the experimental results, producing the expected number n((π 2 /3)-2) - 2\ln n+0.1354 .

Next we combine the MOVE_ONCE rule with reference counters, one per record, that provide estimates of the reference probabilities. We call the resulting reorganization rule MOUCS. We show that, for any δ , α >0 and sufficiently large n , it achieves a cost that approaches the optimum up to an absolute difference of δ with probability higher than 1- α , within a number of accesses that is proportional to n (\lg n) 2 /(αδ 2 ) .

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

Author information

Authors and Affiliations

Authors

Additional information

Received March 10, 2001; revised March 26, 2001.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Hofri, M., Shachnai, H. Efficient Reorganization of Binary Search Trees. Algorithmica 31, 378–402 (2001). https://doi.org/10.1007/s00453-001-0057-z

Download citation

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00453-001-0057-z

Navigation