You are on page 1of 6

B-Tree 171

The next key inserted is IMS07IS045. Comparing this with the elements in the
root, the fourth node is the perfect match for the key. Since the fourth node has
only three keys, this one can be accommodated. The root has to be modificd to
contain this key in it (Figure 7.6e).
I fone more key having USN IMS07IS099 and address 2000 is inserted, this key is
h)
compared with the elements in the root node. This key should be inserted in
fourth child node and it is already full. Therefore, this node is split to accommodate
the new clement. But if it is split directly, the number of child nodes become five
Since, the order of B Tree is four, this is not possible. In such cases, the level of
the tree grows by one more level.
The fourth node is split into two nodes. The keys in the fourth node is equally
distributed between the fourth and the newly created fifth node. These two nodes
will get a new parent node. The first, second and third node form their own
parent. The highest element from all nodes is promoted to their respective parent
nodes. The two parent nodes, in turn, will promote their highest keys to the new
root node (Figure 7.6f).

IMSOSIS013 IMSOS09

IMS041S08sIMSOSIS047 IMS06IS01s IMSO7ISO01IMS071S099

1000 700

Figure 7.6 ) Creation of B-Tree

Another example is considered to illustrate the process of creating B-Trees. The order
of the B-Tree is assumed to be four.
Input Keys - Q, W, E, R, T, Y, U, I, 0, P, A, S, D, F, G, H, J, K, L, Z, X, C, V, B, N, M

a)
E O R
b) Inserting TT

E O
172 File Structures

Inserting Y
c)

E OT R TW
Inserting U
d)

E O Y

e)
ol 9 InsertingI

E o RT
Inserting O

E o 0 R|T
Inserting P
g)

E
B
h) 19TN Inserting A

A EI
R
Inserting S
i)

A EI o Po
R STO
B-Tree 173

Inserting D

k) LY Inserting F

AL D O P

E ETD R S TO
Inserting J

D FI| QT Y

E EL R ST
m) Inserting K

D I1

A D
E FL
174 File Structures

n) Inserting L

A D GH J L K |LouW YT

E F EOI
o)
O Inserting Z

DEI| o T4 E

P) OTzZ| InsertingX

DFI

U
B-Tree 175

q)
LILTZ Inserting C

A IC DI LORST

Inserting V

LD F|

E ET

s) Inserting B

D F o 9 MIIO

b
176 File Structures

t) Inserting N

D EID

A E ICD I
E ELL
V annod N o

u
Inserting M

D EI

E F PoTL
LMNo
Figure7.7 BuildingB-Tree P
7.4.2 Redistribution of Keys
Consider the status of B-Tree given in level
Figure 7.6e. The fourth node of the seconoe
full and insertion of any element into that node ore er
causes tree to grow by
There can be a small change in the methods the one n spa
keys are inserted so that irequ

You might also like