0% found this document useful (0 votes)
61 views14 pages

B - Tree

B-Trees are self-balancing search trees where every node can have multiple children. A B-tree of order m has the following properties: the root has at least 2 children unless it is a leaf, no node has more than m children, internal nodes have at least m/2 children, all leaves are at the same level, and internal nodes contain k-1 keys for k children. New elements are inserted at leaf nodes. Deletion can involve simple leaf or non-leaf deletion, borrowing keys from siblings, demoting root keys, or joining nodes with too few keys. B-Trees remain balanced during operations and can have higher fan-out than binary trees.

Uploaded by

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

B - Tree

B-Trees are self-balancing search trees where every node can have multiple children. A B-tree of order m has the following properties: the root has at least 2 children unless it is a leaf, no node has more than m children, internal nodes have at least m/2 children, all leaves are at the same level, and internal nodes contain k-1 keys for k children. New elements are inserted at leaf nodes. Deletion can involve simple leaf or non-leaf deletion, borrowing keys from siblings, demoting root keys, or joining nodes with too few keys. B-Trees remain balanced during operations and can have higher fan-out than binary trees.

Uploaded by

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

B -TREE

BY:Aastha Tripathi(718001)
Swati Chaurasia(718044)
What is B-Tree?
Definition:

B-Tree is a self balanced search


tree in which every node
contains multiple keys and
has more than two children
B-tree of order m is a tree with the
following properties:
1.The root has at least 2
children,unless it is leaf.
2.No node in the tree has more thanm
children.
3.Every node except for the root and
the leaves have at least[m/2]children.
4.All leaves appear at the same level.
5.An internal node with k children
contains exactly k-1 keys.
Insertion
In a B-Tree, new element must be added only at the leaf node. That means, the new
keyValue is always attached to the leaf node only.

Example: Construct a B-Tree of Order 3 by inserting numbers from 1 to 5


Deletion
Type 1: Simple leaf deletion
Assuming a 5-
way
B-Tree, as 12 29 52
before...

2 7 9 15 22 31 43 56 69 72

Delete 2: Since there are enough


keys in the node, just delete it

B-Trees 6
Type 2: Simple non-leaf deletion

Delete 52
12 29 56
52

7 9 15 22 31 43 56 69 72

Borrow the predecessor


or (in this case) successor

B-Trees 7
Type 3: Enough siblings

12 29
Demote root key and
promote leaf key

7 9 15 22 31 43 56 69

Delete 22

B-Trees 8
Type 3: Enough siblings

12 31

7 9 15 29 43 56 69

B-Trees 9
Type 4: Too few keys in node and
its siblings

12 29 56

Join back together

7 9 15 22 31 43 69 72
Too few keys!
Delete 72

B-Trees 10
Type 4: Too few keys in node and
its siblings

12 29

7 9 15 22 31 43 56 69

B-Trees 11
Comparing Trees
Binary Trees
-Can become unbalanced and lose
their good time complexity(big O)
-AVL trees are strict binary trees
that overcome the balance
problem
-Heap remain balanced but only
prioritise(not order)the keys
Multi-way Trees
-B-Tress can be m-way,they can
have any (odd) number of
children
-One B-Tree,the 2-3(or3-way)B-
Tree,approximates a permanently
balanced binary tree,exchanging
the AVL tree’s balancing
operations for insertion and(more
complex)deletion operations.
THANK YOU

You might also like