What are the differences between B trees and B+ trees?

后端 未结 14 2807
孤城傲影
孤城傲影 2020-12-02 03:18

In a b-tree you can store both keys and data in the internal and leaf nodes, but in a b+ tree you have to store the data in the

相关标签:
14条回答
  • 2020-12-02 03:42

    The principal advantage of B+ trees over B trees is they allow you to pack in more pointers to other nodes by removing pointers to data, thus increasing the fanout and potentially decreasing the depth of the tree.

    The disadvantage is that there are no early outs when you might have found a match in an internal node. But since both data structures have huge fanouts, the vast majority of your matches will be on leaf nodes anyway, making on average the B+ tree more efficient.

    0 讨论(0)
  • 2020-12-02 03:45
    1. In a B tree search keys and data are stored in internal or leaf nodes. But in a B+-tree data is stored only in leaf nodes.
    2. Full scan of a B+ tree is very easy because all data are found in leaf nodes. Full scan of a B tree requires a full traversal.
    3. In a B tree, data may be found in leaf nodes or internal nodes. Deletion of internal nodes is very complicated. In a B+ tree, data is only found in leaf nodes. Deletion of leaf nodes is easy.
    4. Insertion in B tree is more complicated than B+ tree.
    5. B+ trees store redundant search keys but B tree has no redundant value.
    6. In a B+ tree, leaf node data is ordered as a sequential linked list but in a B tree the leaf node cannot be stored using a linked list. Many database systems' implementations prefer the structural simplicity of a B+ tree.
    0 讨论(0)
  • 2020-12-02 03:46

    Example from Database system concepts 5th

    B+-tree B+tree

    corresponding B-tree Btree

    0 讨论(0)
  • 2020-12-02 03:52

    The image below helps show the differences between B+ trees and B trees.

    Advantages of B+ trees:

    • Because B+ trees don't have data associated with interior nodes, more keys can fit on a page of memory. Therefore, it will require fewer cache misses in order to access data that is on a leaf node.
    • The leaf nodes of B+ trees are linked, so doing a full scan of all objects in a tree requires just one linear pass through all the leaf nodes. A B tree, on the other hand, would require a traversal of every level in the tree. This full-tree traversal will likely involve more cache misses than the linear traversal of B+ leaves.

    Advantage of B trees:

    • Because B trees contain data with each key, frequently accessed nodes can lie closer to the root, and therefore can be accessed more quickly.

    B and B+ tree

    0 讨论(0)
  • 2020-12-02 03:52

    **

    The major drawback of B-Tree is the difficulty of Traversing the keys sequentially. The B+ Tree retains the rapid random access property of the B-Tree while also allowing rapid sequential access

    ** ref: Data Structures Using C// Author: Aaro M Tenenbaum

    http://books.google.co.in/books?id=X0Cd1Pr2W0gC&pg=PA456&lpg=PA456&dq=drawback+of+B-Tree+is+the+difficulty+of+Traversing+the+keys+sequentially&source=bl&ots=pGcPQSEJMS&sig=F9MY7zEXYAMVKl_Sg4W-0LTRor8&hl=en&sa=X&ei=nD5AUbeeH4zwrQe12oCYAQ&ved=0CDsQ6AEwAg#v=onepage&q=drawback%20of%20B-Tree%20is%20the%20difficulty%20of%20Traversing%20the%20keys%20sequentially&f=false

    0 讨论(0)
  • 2020-12-02 03:53

    Define "much faster". Asymptotically they're about the same. The differences lie in how they make use of secondary storage. The Wikipedia articles on B-trees and B+trees look pretty trustworthy.

    0 讨论(0)
提交回复
热议问题