Skip to main content Accessibility help

Balancing weight-balanced trees



A weight-balanced tree (WBT) is a binary search tree, whose balance is based on the sizes of the subtrees in each node. Although purely functional implementations on a variant WBT algorithm are widely used in functional programming languages, many existing implementations do not maintain balance after deletion in some cases. The difficulty lies in choosing a valid pair of rotation parameters: one for standard balance and the other for choosing single or double rotation. This paper identifies the exact valid range of the rotation parameters for insertion and deletion in the original WBT algorithm where one and only one integer solution exists. Soundness of the range is proved using a proof assistant Coq. Completeness is proved using effective algorithms generating counterexample trees. For two specific parameter pairs, we also proved in Coq that set operations also maintain balance. Since the difference between the original WBT and the variant WBT is small, it is easy to change the existing buggy implementations based on the variant WBT to the certified original WBT with a rational solution.



Hide All
Adams, S. (1992) Implementing sets efficiently in a functional language, Technical report CSTR 92-10. University of Southampton.
Adams, S. (1993) Efficient sets: A balancing act. J. Funct. Program., 3 (4), 553562.
Adel'son-Vel'skii, G. M. & Landis, E. M. (1962) An algorithm for the organization of information. Dokl. Akad. Nauk SSSR, 146 (2), 263266.
Bertot, Y. & Casteran, P. (2004) Interactive Theorem Proving and Program Development. Coq'Art: The Calculus of Inductive Constructions. Springer.
Borchers, B. (1999) CSDP, a c library for semidefinite programming. Optim. Methods Softw., 11 (1), 613623.
Charguéraud, A. (2010) Program verification through characteristic formulae. In Proceedings of the 15th International Conference on Functional Programming (ICFP). ACM.
Claessen, K. & Hughes, J. (2000) QuickCheck: A lightweight tool for random testing of haskell programs. In Proceedings. of the Fifth International Conference on Functional Programming (ICFP). ACM.
Filliâtre, J.-C. & Letouzey, P. (2004) Functors for proofs and programs. In Programming Languages and Systems, Schmidt, D. (ed), Lecture Notes in Computer Science, vol. 2986. Springer, pp. 370384.
Guibas, L. J. & Sedgewick, R. (1978) A dichromatic framework for balanced trees. In Proceedings of the 19th Annual Symposium on Foundations of Computer Science (SFCS '78). IEEE, pp. 821.
Knuth, D. E. (1998) The Art of Computer Programming: Sorting and Searching. 2nd ed., vol. 3. Addison-Wesley.
Marlow, S. et al. , (2010) Haskell 2010 Language Report, Marlow, S. (ed), Available online (May 2011).
Nievergelt, J. & Reingold, E. M. (1972) Binary search trees of bounded balance. In Proceedings of the Fourth Annual Acm Symposium on Theory of Computing. ACM, pp. 137142.
Okasaki, C. (1998) Purely Functional Data Structures. Cambridge University Pres.
Pugh, W. (1991) The Omega test: A fast and practical integer programming algorithm for dependence analysis. In Proceedings. of the 1991 ACM/IEEE Conference on Supercomputing. ACM.
Roura, S. (2001) A new method for balancing binary search trees. In Automata, Languages and Programming, Orejas, F., Spirakis, P. & van Leeuwen, J. (eds), Lecture Notes in Computer Science, vol. 2076. Springer, pp. 469480.

Balancing weight-balanced trees



Altmetric attention score

Full text views

Total number of HTML views: 0
Total number of PDF views: 0 *
Loading metrics...

Abstract views

Total abstract views: 0 *
Loading metrics...

* Views captured on Cambridge Core between <date>. This data will be updated every 24 hours.

Usage data cannot currently be displayed

Balancing weight-balanced trees

Submit a response


No Discussions have been published for this article.


Reply to: Submit a response

Your details

Conflicting interests

Do you have any conflicting interests? *