Search code examples
data-structurestreeb-tree-index

why at depth 2, a B+ tree of order 2 has a MAXIMUM of 5*5*4 = 100 item?


when I learned B+ tree knowledge , I saw this article, but I don't quite understand how this 100 is calculated. can anyone help explain? enter image description here


Solution

  • There are conflicting definitions of what "order" means in a B-tree.

    On Wikipedia we find:

    The literature on B-trees is not uniform in its terminology.

    Bayer and McCreight (1972), Comer (1979), and others define the order of B-tree as the minimum number of keys in a non-root node.

    With this definition, nodes of a B tree with order 2 can have up to 4 keys and up to 5 children (like depicted in the image).

    When nodes of a 3-layer tree (i.e. depth 2) are filled to the maximum, then the root node has 5 children, and each of those children has 5 children of their own, i.e. the root has 5x5 grandchildren. Each of those grandchildren has 4 keys. So the grandchildren together have 100 keys.