Science of Computer Programming - Special issue on mathematics of program construction
ML for the working programmer (2nd ed.)
ML for the working programmer (2nd ed.)
A Logarithmic Implementation of Flexible Arrays
Proceedings of the Second International Conference on Mathematics of Program Construction
Functional Pearl trouble shared is trouble halved
Haskell '03 Proceedings of the 2003 ACM SIGPLAN workshop on Haskell
Journal of Functional Programming
Translating curry to haskell system demo
Proceedings of the 2005 ACM SIGPLAN workshop on Curry and functional logic programming
The chilling descent: making the transition to a conventional curriculum
Proceedings of the 2008 international workshop on Functional and declarative programming in education
Sorting with bialgebras and distributive laws
Proceedings of the 8th ACM SIGPLAN workshop on Generic programming
Hi-index | 0.00 |
Among the many flavours of balanced binary trees, Braun trees (Braun and Rem, 1983) are perhaps the most circumscribed. For any given node of a Braun tree, the left subtree is either exactly the same size as the right subtree, or one element larger. Braun trees always have minimum height, and the shape of each Braun tree is completely determined by its size. In return for this rigor, algorithms that manipulate Braun trees are often exceptionally simple and elegant, and need not maintain any explicit balance information.Braun trees have been used to implement both flexible arrays (Braun and Rem, 1983; Hoogerwoord, 1992; Paulson, 1996) and priority queues (Paulson, 1996; Bird, 1996). Most operations involving a single element (e.g. adding, removing, inspecting or updating an element) take O(log n) time, since the trees are balanced. We consider three algorithmically interesting operations that manipulate entire trees. First, we give an O(log2 n) algorithm for calculating the size of a tree. Second, we show how to create a tree containing n copies of some element x in O(log n) time. Finally, we describe an order-preserving algorithm for converting a list to a tree in O(n) time. This last operation is not nearly as straightforward as it sounds!