[英]B+ Tree order of 1 & 2
I am confused regarding the maximum and minimum number of keys to be inserted in a B+ Tree having an order of 1 and order of 2.我对要在顺序为 1 和顺序为 2 的 B+ 树中插入的最大和最小键数感到困惑。
In the videos I watch, it is said that the maximum number of keys to be inserted in a node (except the root) is at least m and at most 2m (assuming m is the order).在我看的视频中,据说一个节点(根除外)中插入的最大键数至少为m ,最多为2m (假设m为顺序)。
According to these 2 statements, what is the minimum & maximum number of keys to be inserted in a B+ Tree, having an order of 1 and order of 2?根据这两条语句,在 B+ 树中插入的最小和最大键数是多少,顺序为 1,顺序为 2? I am not sure if the 2 statements above conflict, or I misunderstood something.
我不确定上面的两个陈述是否冲突,或者我误解了一些东西。 Any idea?
任何想法?
Without having the reference to the video, it looks like they use a non-standard definition of the term order , which is the cause of the confusion.在没有参考视频的情况下,看起来他们使用了术语order的非标准定义,这是造成混淆的原因。
The standard definition of order for a tree would be the maximum branching factor, ie the maximum number of children that a node may have.树的顺序的标准定义是最大分支因子,即一个节点可能拥有的最大子节点数。 So, in that definition it is not the minimum , but the maximum , and it is not about the number of keys , but about the number of children .
因此,在该定义中,它不是最小值,而是最大值,并且与键的数量无关,而是与子项的数量有关。
The video's definition would mean that the maximum number of keys would always be an even number, while in reality there is no such requirement.视频的定义意味着最大键数始终为偶数,而实际上并没有这样的要求。 B+ trees may well have a maximum branching factor that is even, making the maximum number of keys odd.
B+ 树的最大分支因子很可能是偶数,从而使最大键数为奇数。
Using standard definition of the term order , we specifically have for B+ trees these constraints:使用术语order的标准定义,我们专门针对 B+ 树具有以下约束:
Here is an example B+ tree with order 4 (standard definition), which corresponds to a B+ tree where the number of keys must be between 1 and 3 -- something that does not fit with the video's definition:下面是一个具有 4 阶(标准定义)的示例 B+ 树,它对应于一个 B+ 树,其中键的数量必须在 1 到 3 之间——这不符合视频的定义:
As you can see, a node can here at most have 4 children, and at most 3 keys.如您所见,一个节点在这里最多可以有 4 个孩子,最多可以有 3 个键。 In your definition where 2m represents the maximum number of keys, the order is actually 2m+1 .
在您的定义中, 2m表示最大键数,顺序实际上是2m+1 。 So you are asking for examples of B+ trees of order 3 and 5, using the standard definition of order .
因此,您要求使用 order 的标准定义来提供 3 和 5阶B+ 树的示例。
Here is an example of order 3 -- the lowest possible order for B+ trees -- which means the number of keys must be either 1 or 2 in each node:下面是 3 阶的示例——B+ 树的最低阶——这意味着每个节点中的键数必须是 1 或 2:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.