B树的理解

B树的定义

Definition[edit]  http://en.wikipedia.org/wiki/B-tree#Technical_description

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 leastm2 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.

B树的高度

1、摘自算法导论第18章 (注意:where the root node is considered to have height 0

《B树的理解》

此图摘自http://blog.csdn.net/v_july_v/article/details/6530142

此方法是的核心思想是关键字的实际总和应该大于或者等于非叶子节点最小总和数与每个非叶子节点最小关键字数之

乘积(另外root节点最少拥有一个关键字)。

2、一棵含有N个关键字的M阶的B-Tree的最大高度是多少?

M阶意味着B-tree每个非叶子节点最多拥有M个孩子,同时最少拥有m2个孩子。为使B-tree达到最大高度,每个节

点的孩子数目应该尽可能的小。因此,root节点只有2个孩子,也就是说第二层只有2个节点。除了root节点之外的非叶子节点都有m2个孩子。

#所在层      #节点数目

1(root为第一层)  1

2 → 2

3 2*m2

2*m2⌉^2

52*m2⌉^3

…………

h2*m2⌉^(h-2)


有N个关键字的B-tree会有N+1个叶子节点。对于h+1层的节点来说,该层节点的个数为N+1>=2*m2⌉^(h-1),可得

h<= logm2⌉(N+1/2) + 1

此方法是的核心思想是叶子节点的实际总和应该大于或者等于叶子节点可以取到的最小值



有N个关键字的B-tree会有N+1个叶子节点的证明可参考:

《B树的理解》


    原文作者:B树
    原文地址: https://blog.csdn.net/vernice/article/details/39942223
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞