Binary trees and number of states in buddy systems
In the paper are computed: the number of binary trees with n nodes and k leaves; the number of leaves in the set of all binary trees with n nodes. These are used to compute the number of states in the buddy system.
š” Research Summary
The paper establishes a precise combinatorial link between ordered binary trees and the state space of the buddy memoryāallocation system. It begins by recalling that the total number of binary trees with n nodes is given by the Catalan number Cā = (1/(n+1))Ā·(2n choose n). To refine this count with respect to the number of leaves, the authors introduce the Narayana numbers N(n,k) = (1/n)Ā·(n choose k)Ā·(n choose kā1), which enumerate the trees that have exactly k leaves. These numbers satisfy Ī£ā N(n,k) = Cā, confirming that they partition the Catalan set.
Next, the paper derives the total number of leaves across all binary trees of size n. By summing kĀ·N(n,k) over k and applying standard binomial identities, the authors obtain a compact expression Lā = CāĀ·(n+1)/2. Consequently, the expected number of leaves in a uniformly random nānode binary tree is (n+1)/2. This result also yields the average depth and balance properties of random trees, which are relevant for analyzing hierarchical data structures.
The core contribution lies in mapping these tree counts to the buddy system. In a buddy allocator, memory is divided into blocks whose sizes are powers of two; allocation and deallocation correspond to splitting and merging nodes of a perfect binary tree. If the total memory size is 2^m, each possible configuration of allocated and free blocks corresponds uniquely to a binary tree with m internal nodes (or equivalently, m+1 leaves). Therefore, the total number of distinct states of the buddy system is exactly the Catalan number Cā. Moreover, the number of states in which there are k blocks of a given size matches the Narayana number N(m,k).
By providing closedāform formulas for both the overall state count and the distribution of block sizes, the paper replaces earlier empirical or asymptotic estimates with exact combinatorial expressions. This has several practical implications: (1) the exponential growth of Cā with m quantifies how the state space explodes as memory size increases, informing the design of stateāexploration algorithms; (2) knowing N(m,k) enables prediction of the likelihood of particular blockāsize configurations, which can guide preāallocation strategies, fragmentation mitigation, and garbageācollection policies; (3) the leafācount result Lā offers a quick way to estimate the average number of free blocks in a random state, useful for performance modeling.
The authors conclude that the rigorous enumeration of binaryātree configurations provides a solid theoretical foundation for analyzing and optimizing buddy allocators. Their formulas can be directly incorporated into simulation tools, analytical models, and even hardwareālevel verification suites to assess memoryāmanagement efficiency, worstācase fragmentation, and allocation latency. Overall, the work bridges classic combinatorial theory with modern systems engineering, delivering exact, actionable insights for both researchers and practitioners in computer architecture and operatingāsystem design.
Comments & Academic Discussion
Loading comments...
Leave a Comment