Skip to main content
    • Aa
    • Aa

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.

Linked references
Hide All

This list contains references from the content that can be linked to their source. For a full set of references and notes please see the PDF or HTML where available.

Y. Bertot & P. Casteran (2004) Interactive Theorem Proving and Program Development. Coq'Art: The Calculus of Inductive Constructions. Springer.

J.-C. Filliâtre & P. Letouzey (2004) Functors for proofs and programs. In Programming Languages and Systems, D. Schmidt (ed), Lecture Notes in Computer Science, vol. 2986. Springer, pp. 370384.

L. J. Guibas & R. Sedgewick (1978) A dichromatic framework for balanced trees. In Proceedings of the 19th Annual Symposium on Foundations of Computer Science (SFCS '78). IEEE, pp. 821.

C. Okasaki (1998) Purely Functional Data Structures. Cambridge University Pres.

S. Roura (2001) A new method for balancing binary search trees. In Automata, Languages and Programming, F. Orejas , P. Spirakis & J. van Leeuwen (eds), Lecture Notes in Computer Science, vol. 2076. Springer, pp. 469480.

Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *


Full text views

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

Abstract views

Total abstract views: 108 *
Loading metrics...

* Views captured on Cambridge Core between September 2016 - 23rd June 2017. This data will be updated every 24 hours.