1. B tree
B tree follow binary search tree property
Order of tree is the number of pointers stored in tree.
If order = 3 then number of key elements in each node =2 (i.e, order-1)
Btree is used for indexing
The node values are primary keys
2. Insertion into B tree
8
Insert the following elements into B-tree of order 3
8 5 7 1 3 9
Since order of Btree =3
Number of keys that can be stored in each node = 2
Number of pointers in each node =3 Keys
pointers
3. Insert 5
5
Since there is place to insert one more key in the root node, we insert 5 in the
root node itself
Since 5 is < 8 we insert 5 to the left of 8 in the root node
8
4. Insert 7
7
We cannot insert 7 in root node as each node can store only 2 keys
So of the three elements 5 7 and 8 , the middle element is 7
So we split as shown below.
In this way all the elements that are less than 7 is to the left of 7
And all the elements that are greater than 7 is to the right
5 8
5. Insert 1
7
Since 1 is < 7 , we move to the node that is left of root node
In left node, since 1< 5 we insert 1 as shown below
1 85
6. Insert 3
3
Since 3 is < 7 , we move to the node that is left of root node
In left node, since 1<3 and 3< 5 we have to insert 3 in the left node
As a node cannot store more than 2 keys we cannot insert 3
So n 1,3,5 the middle element is 3 and so we move 3 to the root node
As follows
1 8
7
5