The Wayback Machine - https://web.archive.org/web/20241127234228/https://www.geeksforgeeks.org/difference-between-b-tree-and-b-tree/
Open In App

Difference between B tree and B+ tree

Last Updated : 25 Jan, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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. Some conditions must be held 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, 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:

Basis of Comparison B tree B+ tree
Pointers All internal and leaf nodes have data pointers Only leaf nodes have data pointers
Search Since all keys are not available at leaf, search often takes more time. All keys are at leaf nodes, hence search is faster and more accurate.
Redundant Keys No duplicate of keys is maintained in the tree. Duplicate of keys are maintained and all nodes are present at the leaf.
Insertion Insertion takes more time and it is not predictable sometimes. Insertion is easier and the results are always the same.
Deletion Deletion of the internal node is very complex and the tree has to undergo a lot of transformations. Deletion of any node is easy because all node are found at leaf.
Leaf Nodes Leaf nodes are not stored as structural linked list. Leaf nodes are stored as structural linked list.
Access Sequential access to nodes is not possible Sequential access is possible just like linked list
Height For a particular number nodes height is larger Height is lesser than B tree for the same number of nodes
Application B-Trees used in Databases, Search engines B+ Trees used in Multilevel Indexing, Database indexing
Number of Nodes Number of nodes at any intermediary level ‘l’ is 2l. Each intermediary node can have n/2 to n children.

Previous Article
Next Article

Similar Reads

Difference between General tree and Binary tree
General Tree: In the data structure, General tree is a tree in which each node can have either zero or many child nodes. It can not be empty. In general tree, there is no limitation on the degree of a node. The topmost node of a general tree is called the root node. There are many subtrees in a general tree. The subtree of a general tree is unorder
2 min read
Difference between Binary tree and B-tree
B-Tree : B-Tree is known as a self-balancing tree as its nodes are sorted in the inorder traversal. Unlike the binary trees, 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 adjusts automatically at each update. In the B-tree data is sor
7 min read
Difference between Binary Search Tree and AVL Tree
Binary Search Tree:A binary Search Tree is a node-based binary tree data structure that has the following properties: The left subtree of a node contains only nodes with keys lesser than the node’s key.The right subtree of a node contains only nodes with keys greater than the node’s key.The left and right subtree each must also be a binary search t
2 min read
Difference between Spanning Tree Protocol (STP) and Rapid Spanning Tree Protocol (RSTP)
Spanning Tree Protocol (STP) and Rapid Spanning Tree Protocol (RSTP), are designed to avoid network loops in Ethernet. It provide loop-free logical topology. They were both designed to provide network reliability and particularly avoid broadcast radiation, but the major differences are on the rate, functionality and versatility. In this article we
5 min read
Difference between Binary Tree and Binary Search Tree
Binary Tree Data Structure:A tree whose elements have at most 2 children is called a binary tree. Since each element in a binary tree can have only 2 children, we typically name them the left and right children. Binary Search Tree Data Structure (BST):A binary search tree is a hierarchical data structure where each node has at most two children, wi
2 min read
Minimum difference between any two weighted nodes in Sum Tree of the given Tree
Given a tree of N nodes, the task is to convert the given tree to its Sum Tree(including its own weight) and find the minimum difference between any two node's weight of the sum tree. Note: The N nodes of the given tree are given in the form of top to bottom with N-1 line where each line describes two nodes that are connected. Examples: Input: Outp
11 min read
Maximum sum of a subsequence having difference between their indices equal to the difference between their values
Given an array A[] of size N, the task is to find the maximum sum of a subsequence such that for each pair present in the subsequence, the difference between their indices in the original array is equal to the difference between their values. Examples: Input: A[] = {10, 7, 1, 9, 10, 15}, N = 6Output: 26Explanation: Subsequence: {7, 9, 10}. Indices
5 min read
Complexity of different operations in Binary tree, Binary Search Tree and AVL tree
In this article, we will discuss the complexity of different operations in binary trees including BST and AVL trees. Before understanding this article, you should have a basic idea about Binary Tree, Binary Search Tree, and AVL Tree. The main operations in a binary tree are: search, insert and delete. We will see the worst-case time complexity of t
4 min read
Comparison between Height Balanced Tree and Weight Balanced Tree
What is Height Balanced Tree? Self-Balancing binary search trees are the height-balanced binary tree is one for which at every node, the absolute value of the difference in heights of the left and right subtree is no larger than one. An empty tree is height-balanced. A non-empty binary tree T is balanced if: The left subtree of T is balanced.The ri
4 min read
Comparison between Fenwick Tree vs Segment Tree - with Similarities and Differences
Fenwick Tree (Binary Indexed Tree) and Segment Tree are both data structures used for efficient range query and update operations on an array. Here's a tabular comparison of these two data structures. Similarities between the Fenwick tree and Segment treeHere are some of the areas where Fenwick Tree is similar to Segment Tree: Array type: Both Fenw
2 min read
Convert a Generic Tree(N-array Tree) to Binary Tree
Prerequisite: Generic Trees(N-array Trees) In this article, we will discuss the conversion of the Generic Tree to a Binary Tree. Following are the rules to convert a Generic(N-array Tree) to a Binary Tree: The root of the Binary Tree is the Root of the Generic Tree.The left child of a node in the Generic Tree is the Left child of that node in the B
13 min read
Difference between sums of odd position and even position nodes for each level of a Binary Tree
Given a Binary Tree, the task is to find the absolute difference between the sums of odd and even positioned nodes. A node is said to be odd and even positioned if its position in the current level is odd and even respectively. Note that the first element of each row is considered as odd positioned.Examples: Input: 5 / \ 2 6 / \ \ 1 4 8 / / \ 3 7 9
8 min read
Difference between Decision Table and Decision Tree
1. Decision Table: Decision Table is just a tabular representation of all conditions and actions. Decision Table are always used whenever the processing logic is very complicated and involves multiple conditions. The main components used for the formation of the Data Table are Conditions Stubs, Action Stubs, and rules. Types of decision tables: Ext
3 min read
Difference between sum of even and odd valued nodes in a Binary Tree
Given a binary tree, the task is to find the absolute difference between the even valued and the odd valued nodes in a binary tree. Examples: Input: 5 / \ 2 6 / \ \ 1 4 8 / / \ 3 7 9 Output: 5 Explanation: Sum of the odd value nodes is: 5 + 1 + 3 + 7 + 9 = 25 Sum of the even value nodes is: 2 + 6 + 4 + 8 = 20 Absolute difference = (25 – 20) = 5. In
10 min read
Difference between sums of odd level and even level nodes in an N-ary Tree
Given an N-ary Tree rooted at 1, the task is to find the difference between the sum of nodes at the odd level and the sum of nodes at even level. Examples: Input: 4 / | \ 2 3 -5 / \ / \ -1 3 -2 6Output: 10Explanation:Sum of nodes at even levels = 2 + 3 + (-5) = 0Sum of nodes at odd levels = 4 + (-1) + 3 + (-2) + 6 = 10Hence, the required difference
9 min read
Difference between Minimum Spanning Tree and Shortest Path
Spanning tree: A spanning tree (T) of an undirected graph(G) is a subgraph which is a tree that includes all the vertices of a graph (G) and the minimum number of edges required to connect the graph (G). And it is a known maximal set of edges with no cycles. Properties: If a graph(G) is not connected then it does not contain a spanning tree (i.e. i
4 min read
Difference between Stack and Tree
Stack: A Stack is a linear data structure in which elements can be inserted and deleted only from one side of the list, called the top. Insertion is called push operation and deletion is called pop operation in case of the stack. The order of insertion and deletion may be LIFO(Last In First Out) i.e., the element inserted latest to the stack will a
2 min read
Difference between Tree edge and Back edge in graph
Tree Edge: It is an edge that is present in the tree obtained after performing DFS on the graph. All the Green edges are tree edges as shown in the below image. Back Edge: It is an edge (u, v) such that v is an ancestor of node u but not part of the DFS Traversal of the tree. Edge from 5 to 4 is a back edge. The presence of a back edge indicates a
1 min read
Difference between odd level and even level leaf sum in given Binary Tree
Given a Binary Tree, the task is to find the difference of the sum of leaf nodes at the odd level and even level of the given tree. Examples: Input: Output: -12Explanation: Following are the operations performed to get the result.odd_level_sum = 0, even_level_sum = 0Level 1: No leaf node, so odd_level_sum = 0Level 2: No leaf node, so even_level_sum
13 min read
What is the difference between Heap and Red-Black Tree?
What is Heap? A Heap is a special Tree-based data structure in which the tree is a complete binary tree. There are two types of heap - Min heap and Max heap. To learn more about heap, go through the following article: Introduction to Heap What is a Red-Black Tree?The red-Black tree is a self-balancing binary search tree in which each node contains
2 min read
Difference between an array and a tree
Array:An array is a collection of homogeneous(same type) data items stored in contiguous memory locations. For example, if an array is of type “int”, it can only store integer elements and cannot allow the elements of other types such as double, float, char, etc. The array is a linear data structure in which elements are stored at contiguous memory
3 min read
Maximum difference between node and its ancestor in Binary Tree
Given a Binary tree, The task is to find the maximum value by subtracting the value of node B from the value of node A, where A and B are two nodes of the binary tree and A is an ancestor of B. Examples: Input: Output: 7Explanation: We can have various ancestor-node difference, some of which are given below : 8 – 3 = 5 , 3 – 7 = -4, 8 – 1 = 7, 10 –
10 min read
Difference Between Graph and Tree
Graphs and trees are two fundamental data structures used in computer science to represent relationships between objects. While they share some similarities, they also have distinct differences that make them suitable for different applications. What is Graph?A graph data structure is a collection of nodes (also called vertices) and edges that conn
2 min read
Git - Difference Between HEAD, Working Tree and Index
Git, a popular version control system, helps developers track changes and collaborate on projects efficiently. To use Git effectively, it's essential to understand its key components: HEAD, the working tree, and the index (also known as the staging area). This article will explain these concepts and highlight their differences, helping you gain a d
4 min read
Difference between Suffix Array and Suffix Tree
Suffix Array and Suffix Tree are data structures used for the efficient string processing and pattern matching. They provide the different ways to the store and query substrings each with the unique characteristics and use cases. Understanding the differences between them helps in the choosing the right data structure for the specific applications.
3 min read
Difference between sums of odd level and even level nodes of a Binary Tree
Given a Binary Tree, find the difference between the sum of nodes at odd level and the sum of nodes at even level. Consider root as level 1, left and right children of root as level 2 and so on. For example, in the following tree, sum of nodes at odd level is (5 + 1 + 4 + 8) which is 18. And sum of nodes at even level is (2 + 6 + 3 + 7 + 9) which i
15+ min read
Difference between Ring Topology and Tree Topology
In Computer network there are some important factors which need to be considered when choosing a topology for a network. Some of the network topologies are: Ring Topology and Tree Topology. Knowing the differences between the two makes it possible to decide which integrated network is most suitable depending on size, complexity, or needs. What is R
5 min read
Difference between Mesh Topology and Tree Topology
While using a network, the topology used is very important when designing it for better and optimal performance, expanded capability, and dependability. Mesh is one of the frequently used topologies along with Tree topology It has certain advantages and drawback as well. Comparing Mesh Topology and Tree Topology that allows network administrators t
4 min read
Difference between Tree Topology and Bus Topology
Network arrangement of various elements, like links and nodes, is termed as network topology. It decides how nodes in a network are different from each other, interlinked, and how the data flows between them. There are different purposes served by different topologies, and the choice varies as per the need of the network. In this article we will se
5 min read
Difference between Star Topology and Tree Topology
Network topology is crucial thing and it may affect the performance and communication of the devices. So, we need to choose the correct network topology for our organization. We should keep in mind while designing - optimal network design, its cost and upgrade possibility. Some most common types in which network topologies are available. star topol
5 min read
three90RightbarBannerImg