**B-Tree:**

B-Tree is known as a self-balancing tree as its nodes are sorted in the inorder traversal. In B-tree, a node can have more than two children. B-tree has a height of logM N (Where ‘M’ is the order of tree and N is the number of nodes). And the height is adjusted automatically at each update. In the B-tree data is sorted in a specific order, with the lowest value on the left and the highest value on the right. To insert the data or key in B-tree is more complicated than a binary tree.

There are some conditions that must be hold by the B-Tree:

- All the leaf nodes of the B-tree must be at the same level.
- Above the leaf nodes of the B-tree, there should be no empty sub-trees.
- B- tree’s height should lie as low as possible.

**B+ Tree**

B+ tree eliminates the drawback B-tree used for indexing by storing data pointers only at the leaf nodes of the tree. Thus, the structure of leaf nodes of a B+ tree is quite different from the structure of internal nodes of the B tree. It may be noted here that, since data pointers are present only at the leaf nodes, the leaf nodes must necessarily store all the key values along with their corresponding data pointers to the disk file block, in order to access them. Moreover, the leaf nodes are linked to providing ordered access to the records. The leaf nodes, therefore form the first level of the index, with the internal nodes forming the other levels of a multilevel index. Some of the key values of the leaf nodes also appear in the internal nodes, to simply act as a medium to control the searching of a record.

Let’s see the difference between B-tree and B+ tree:

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

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Sub-tree with minimum color difference in a 2-coloured tree
- Minimum difference between any two weighted nodes in Sum Tree of the given Tree
- Difference between General tree and Binary tree
- Difference between Binary tree and B-tree
- Difference between Binary Tree and Binary Search Tree
- Maximum sub-tree sum in a Binary Tree such that the sub-tree is also a BST
- Complexity of different operations in Binary tree, Binary Search Tree and AVL tree
- Convert a Binary Search Tree into a Skewed tree in increasing or decreasing order
- Overview of Data Structures | Set 3 (Graph, Trie, Segment Tree and Suffix Tree)
- Print Binary Tree levels in sorted order | Set 3 (Tree given as array)
- Check if max sum level of Binary tree divides tree into two equal sum halves
- Convert an arbitrary Binary Tree to a tree that holds Children Sum Property
- Given level order traversal of a Binary Tree, check if the Tree is a Min-Heap
- Check whether a binary tree is a complete tree or not | Set 2 (Recursive Solution)
- Convert a given Binary tree to a tree that holds Logical OR property
- Construct XOR tree by Given leaf nodes of Perfect Binary Tree
- Check if a given Binary Tree is height balanced like a Red-Black Tree
- Convert a given Binary tree to a tree that holds Logical AND property
- Cartesian tree from inorder traversal | Segment Tree
- Remove all leaf nodes from a Generic Tree or N-ary Tree

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.