How do you figure out the maximum depth of a B-tree?
Say you had a B-tree of order 1625, meaning each node has 1625 pointers and 1624 elements.
What is the maximum depth of the tree if it contains 85,000,000 keys?
How do you figure out the maximum depth of a B-tree?
Say you had a B-tree of order 1625, meaning each node has 1625 pointers and 1624 elements.
What is the maximum depth of the tree if it contains 85,000,000 keys?
Maximum depth depends on the algorithms used to manipulate the tree, and what their worse-case behavior is (I don't know the specifics, sorry). The approximate depth is log(N)/log(1625), assuming perfect balancing.
A B+-tree might be slightly deeper because only the leaves hold keys, but the difference is probably negligible. It also might be shallower if you consider that each non-leaf node only has to hold pointers.
The worst case height for a B-Tree of order m is logm/2n.
See: http://en.wikipedia.org/wiki/B-tree#Best_case_and_worst_case_heights
Assuming
... this tree would have a minimum depth of 3, i.e. it would have a root node, one layer of non-leaf nodes, and the layer of leaf nodes. ... this tree would have a maximum depth of 3 as well.
To compute the depth in the most optimal case:
We made two divisions so the tree depth is 3.
The worse case would happen if all nodes had had to be split, hence holding on average the order/2 (no rounding) pointers. The calculation for the worse case is similar, we just divide by order / 2 , i.e. 812.5 in our case, producing 104,616 leaf-nodes, 129 non-leaf nodes at the level above the leaves, and finally one root to keep track of these 129 non-leaf nodes.