Number of nodes in a B-Tree

落花浮王杯 提交于 2019-12-25 11:54:37

问题


How many nodes does a resulting B-Tree(min degree 2) have if I insert numbers from 1 to n in order?

I tried inserting nodes from 1 to 20 there was a series for the number of nodes coming but i could not generalize it.

Can anyone please help me derive the formula for this.


回答1:


It will depend on the order of the B-Tree. The order of a BTree is the maximum number of children nodes a non-leaf node may hold (which is one more than the minimum number of keys such a node could hold).

According to Knuth's definition, a B-tree of order m is a tree which satisfies the following properties:

  1. Every node has at most m children.
  2. Every non-leaf node (except root) has at least ⌈m⁄2⌉ children.
  3. The root has at least two children if it is not a leaf node.
  4. A non-leaf node with k children contains k−1 keys.
  5. All leaves appear in the same level, and internal vertices carry no information.

So in your case when you are inserting 20 keys if the order is m then based on the conditions mentioned above you can derive a set of inequalities that describes the possible value of m. But there is no equality formula that says the number of internal nodes in a B-Tree.



来源:https://stackoverflow.com/questions/26238014/number-of-nodes-in-a-b-tree

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!