b+ tree intro,uses,insertion and deletion

22
B+ Trees

Upload: hamid-50

Post on 13-Apr-2017

79 views

Category:

Education


2 download

TRANSCRIPT

Page 1: B+ tree intro,uses,insertion and deletion

B+ Trees

Page 2: B+ tree intro,uses,insertion and deletion

Prepared byHamid ali Dana

CS & IT Ajk university Mzd

From Gilgit Baltistan

Page 3: B+ tree intro,uses,insertion and deletion

What is b+ tree

A B+ tree is a data structure often used in the implementation of database indexes.  Each node of the tree contains an ordered list of keys and pointers to lower level nodes in the tree.

A B+ tree is a balanced tree in which every path from the root of the tree to a leaf is of the same length.

Page 4: B+ tree intro,uses,insertion and deletion

B+- Tree Characteristics• Data records are only stored in the leaves.• Internal nodes store just keys.• All data is stored at the leaf nodes (leaf pages); all

other nodes (index pages) only store keys.• All the leaf nodes are interconnected with each other

leaf nodes for faster access.• Keys are used for directing a search to the proper leaf. • If a target key is less than a key in an internal node,

then the pointer just to its left is followed. • If a target key is greater or equal to the key in the

internal node, then the pointer to its right is followed. • B+ Tree combines features of ISAM (Indexed

Sequential Access Method) and B Trees.

Page 5: B+ tree intro,uses,insertion and deletion

B+ TREEINTERNAL NODE / INDEX nodeS

LEAF NODES / DATA nodeS

The linked list allows rapid traversal.

Page 6: B+ tree intro,uses,insertion and deletion

Structure of b+ tree

Page 7: B+ tree intro,uses,insertion and deletion

How to create or insert in B+:==2,4,7,10,17,21,28if n=4 n is the orderkey=n-1=4-1=3

2

Page 8: B+ tree intro,uses,insertion and deletion

==2,4,7,10,17,21,28

2 4

Page 9: B+ tree intro,uses,insertion and deletion

==2,4,7,10,17,21,28

2 4 7

Page 10: B+ tree intro,uses,insertion and deletion

==2,4,7,10,17,21,28

4

2 4 7 10

Page 11: B+ tree intro,uses,insertion and deletion

==2,4,7,10,17,21,28

4 7

2 4 7 10 17

Page 12: B+ tree intro,uses,insertion and deletion

==2,4,7,10,17,21,28

4 7

2 4 7

10

10 17 21

Page 13: B+ tree intro,uses,insertion and deletion

==2,4,7,10,17,21,28

10 17

2 4 7 17 21 28

4

7

10

Page 14: B+ tree intro,uses,insertion and deletion

Deletion Process:Deletion of 28:

10 17

2 4 7 17 21 28

4

7

10

Page 15: B+ tree intro,uses,insertion and deletion

Deleted 28:

4 7

2 4 7

10

10 17 21

Page 16: B+ tree intro,uses,insertion and deletion

Deletion of 4:

4 7

2 4 7

10

10 17 21

Page 17: B+ tree intro,uses,insertion and deletion

Deleted 4:

2 7 10 17

7 10

21

Page 18: B+ tree intro,uses,insertion and deletion

Deletion of 7:

2 7 10 17

7 10

21

Page 19: B+ tree intro,uses,insertion and deletion

Deleted 7:

2

10

10 17 21

Page 20: B+ tree intro,uses,insertion and deletion

Deletion of 2:

2

10

10 17 21

Page 21: B+ tree intro,uses,insertion and deletion

Deleted 2:

10 17 21

Page 22: B+ tree intro,uses,insertion and deletion

Thank you