0% found this document useful (0 votes)
35 views4 pages

B Trees

Uploaded by

datalogdigital
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views4 pages

B Trees

Uploaded by

datalogdigital
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

B Trees

B trees are extended binary search trees that are specialized in m-way searching,
since the order of B trees is 'm'. Order of a tree is defined as the maximum number
of children a node can accommodate. Therefore, the height of a b tree is relatively
smaller than the height of AVL tree and RB tree.

They are general form of a Binary Search Tree as it holds more than one key and
two children.

The various properties of B trees include −


 Every node in a B Tree will hold a maximum of m children and (m-1) keys, since
the order of the tree is m.
 Every node in a B tree, except root and leaf, can hold at least m/2 children
 The root node must have no less than two children.
 All the paths in a B tree must end at the same level, i.e. the leaf nodes must be at
the same level.
 A B tree always maintains sorted data.

B trees are also widely used in disk access, minimizing the disk access time since
the height of a b tree is low.

Note − A disk access is the memory access to the computer disk where the
information is stored and disk access time is the time taken by the system to
access the disk memory.

Basic Operations of B Trees

Insertion operation
The insertion operation for a B Tree is done similar to the Binary Search Tree but
the elements are inserted into the same node until the maximum keys are reached.
The insertion is done using the following procedure −

Step 1 − Calculate the maximum (m−1)(m−1) and, minimum (⌈m2⌉−1)(⌈m2⌉−1) number


of keys a node can hold, where m is denoted by the order of the B Tree.
Step 2 − The data is inserted into the tree using the binary search insertion and
once the keys reach the maximum number, the node is split into half and the
median key becomes the internal node while the left and right keys become its
children.

Step 3 − All the leaf nodes must be on the same level.


The keys, 5, 3, 21, 9, 13 are all added into the node according to the binary search
property but if we add the key 22, it will violate the maximum key property. Hence,
the node is split in half, the median key is shifted to the parent node and the
insertion is then continued.

Another hiccup occurs during the insertion of 11, so the node is split and median is
shifted to the parent.
While inserting 16, even if the node is split in two parts, the parent node also
overflows as it reached the maximum keys. Hence, the parent node is split first and
the median key becomes the root. Then, the leaf node is split in half the median of
leaf node is shifted to its parent.

You might also like