B-Tree |
Data Structure - B-TreeIntroductionB-tree is a self-balancing tree data structure. In a B-tree each node may contain a large number of keys and children. The number of children and keys in a B-tree is defined by a single numerical parameter - order. B-tree is a generalization of 2-3-4 tree [3]. Facts about B-Tree of order K:
B-Tree of order 5 built from the array of values (7, 16, 1, 2, 5, 6, 12, 9, 21, 18) is shown below. Each node has 9 slots: 5 slots for child references and 4 slots for key values: Key slots contain either a number or when empty an underscore '_' symbol, Reference slots that have link to a child node contain '.' symbol.
ImplementationC# implementation that follows description of Comer's article [1] is given in two flavors:
Python implementation of 2-3-4 tree with add operation as described in Wikipedia article [3]: Open on github 2-3-4 tree built from the input ['a', 'b', 'c', 'p', 'q', 'r', 's', 'd', 't', 'e'] is shown below: Usage
Links
|