📜  B树和B +树之间的区别

📅  最后修改于: 2021-08-29 10:55:44             🧑  作者: Mango

B树:
B树被称为自平衡树,因为其节点按顺序遍历排序。在B树中,一个节点可以有两个以上的子节点。 B树的高度为logM N(其中“ M”是树的顺序,N是节点数)。并在每次更新时自动调整高度。在B树中,数据按特定顺序排序,左侧为最小值,右侧为最大值。在B树中插入数据或密钥比二叉树复杂。

B树必须满足一些条件:

  • B树的所有叶节点必须处于同一级别。
  • 在B树的叶子节点上方,不应有空的子树。
  • B树的高度应尽可能低。

B +树
B +树通过仅在树的叶节点处存储数据指针,消除了用于索引的B树的缺点。因此,B +树的叶子节点的结构与B树的内部节点的结构完全不同。在这里应该注意,由于数据指针仅存在于叶节点,因此叶节点必须必须将所有键值及其对应的数据指针存储到磁盘文件块,以便访问它们。此外,叶节点链接到提供对记录的有序访问。因此,叶节点形成索引的第一层,而内部节点形成多级索引的其他层。叶子节点的某些关键值也出现在内部节点中,以简单地充当控制记录搜索的媒介。

让我们看一下B树和B +树之间的区别:

S.NO B tree B+ tree
1. All internal and leaf nodes have data pointers Only leaf nodes have data pointers
2. Since all keys are not available at leaf, search often takes more time. All keys are at leaf nodes, hence search is faster and accurate..
3. No duplicate of keys is maintained in the tree. Duplicate of keys are maintained and all nodes are present at leaf.
4. Insertion takes more time and it is not predictable sometimes. Insertion is easier and the results are always the same.
5. Deletion of internal node is very complex and tree has to undergo lot of transformations. Deletion of any node is easy because all node are found at leaf.
6. Leaf nodes are not stored as structural linked list. Leaf nodes are stored as structural linked list.
7. No redundant search keys are present.. Redundant search keys may be present..

如果您希望与行业专家一起参加现场课程,请参阅《 Geeks现场课程》和《 Geeks现场课程美国》。