简体   繁体   English

记录的B +树查找编号

[英]B+ Tree Finding Number oF records

Recently during my studies i came across a question like this 最近我在学习期间遇到了这样的问题

What is minimum levels of B+ tree and B Tree index required for 5000 keys and order of B+ tree node (P) is 10. (Assume P is max pointer possible to store in B+ tree node) 5000个密钥所需的B +树和B树索引的最低级别是多少,B +树节点(P)的顺序是10。(假设P是可以存储在B +树节点中的最大指针)

I calculated for Btree it happens to be 4 levels . 我为Btree计算得出它恰好是4个级别。 While attempting for B+ tree i ended up in a confusion . 在尝试B +树时,我陷入了混乱。 Is the order mentioned in question is internal node order or leaf node order. 问题中提到的顺序是内部节点顺序还是叶节点顺序。 if it was internal node order then how is it possible to calculate Number of levels required if the order of leaf node is not known. 如果是内部节点顺序,那么如果叶节点的顺序未知,则如何计算所需的级别数。 Could some one help me ? 有人可以帮我吗?

You are right, the question should have mentioned the leaf node capacity. 没错,问题应该提到叶子节点的容量。

Whatever it might be - let's call it L - the number of leaf nodes required is clearly ceiling(N / L) because the leaf node layer must contain all the data. 不管是什么-我们称其为L所需的叶子节点数显然是ceiling(N / L)因为叶子节点层必须包含所有数据。 If every leaf node can hold up to 10 records (data items) then we get a minimum leaf node count of 500. Once you have the required number of leaf nodes, you can compute the required height of the index part as usual for a B-tree. 如果每个叶节点最多可以容纳10个记录(数据项),那么我们得到的最小叶节点数为500。一旦具有所需数目的叶节点,便可以像平常一样为B计算索引部分的所需高度。 -树。

In our case the lowest layer of internal nodes (ie the bottom-most layer of the index part of the B+ tree) needs to have at least 500 outgoing pointers in order to reach each leaf. 在我们的情况下,内部节点的最低层(即B +树的索引部分的最底层)需要至少500个传出指针才能到达每个叶子。 ceiling(log(500)/log(10)) is 3, which gives you the minimum number of index levels above the sequence set. ceiling(log(500)/log(10))为3,它为您提供了高于序列集的最小索引级别数。 Hence the B+ tree also has at least 4 levels in this case, just like the plain B-tree. 因此,在这种情况下,B +树也至少具有4级,就像普通的B树一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM