<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
a	O
B-tree	B-Architecture
is	O
a	O
self-balancing	O
tree	B-Application
data	I-Application
structure	I-Application
that	O
maintains	O
sorted	O
data	O
and	O
allows	O
searches	O
,	O
sequential	O
access	O
,	O
insertions	O
,	O
and	O
deletions	O
in	O
logarithmic	O
time	O
.	O
</s>
<s>
The	O
B-tree	B-Architecture
generalizes	O
the	O
binary	B-Language
search	I-Language
tree	I-Language
,	O
allowing	O
for	O
nodes	B-Data_Structure
with	O
more	O
than	O
two	O
children	O
.	O
</s>
<s>
Unlike	O
other	O
self-balancing	B-Data_Structure
binary	I-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
,	O
the	O
B-tree	B-Architecture
is	O
well	O
suited	O
for	O
storage	O
systems	O
that	O
read	O
and	O
write	O
relatively	O
large	O
blocks	O
of	O
data	O
,	O
such	O
as	O
databases	O
and	O
file	B-Application
systems	I-Application
.	O
</s>
<s>
B-trees	B-Architecture
were	O
invented	O
by	O
Rudolf	O
Bayer	O
and	O
Edward	O
M	O
.	O
McCreight	O
while	O
working	O
at	O
Boeing	O
Research	O
Labs	O
,	O
for	O
the	O
purpose	O
of	O
efficiently	O
managing	O
index	B-Data_Structure
pages	O
for	O
large	O
random-access	O
files	O
.	O
</s>
<s>
McCreight	O
has	O
said	O
that	O
"	O
the	O
more	O
you	O
think	O
about	O
what	O
the	O
B	O
in	O
B-trees	B-Architecture
means	O
,	O
the	O
better	O
you	O
understand	O
B-trees.	O
"	O
</s>
<s>
In	O
2011	O
Google	B-Application
developed	O
the	O
C++	O
B-Tree	B-Architecture
,	O
reporting	O
a	O
50-80	O
%	O
reduction	O
in	O
memory	O
use	O
for	O
small	O
data	O
types	O
and	O
improved	O
performance	O
for	O
large	O
data	O
sets	O
when	O
compared	O
to	O
a	O
Red-Black	O
tree	O
.	O
</s>
<s>
According	O
to	O
Knuth	O
's	O
definition	O
,	O
a	O
B-tree	B-Architecture
of	O
order	O
m	O
is	O
a	O
tree	O
which	O
satisfies	O
the	O
following	O
properties	O
:	O
</s>
<s>
Every	O
non-leaf	B-Data_Structure
node	O
has	O
at	O
least	O
two	O
children	O
.	O
</s>
<s>
A	O
non-leaf	B-Data_Structure
node	O
with	O
k	O
children	O
contains	O
k1	O
keys	O
.	O
</s>
<s>
Each	O
internal	O
node	O
's	O
keys	O
act	O
as	O
separation	O
values	O
which	O
divide	O
its	O
subtrees	B-Application
.	O
</s>
<s>
For	O
example	O
,	O
if	O
an	O
internal	O
node	O
has	O
3	O
child	O
nodes	B-Data_Structure
(	O
or	O
subtrees	B-Application
)	O
then	O
it	O
must	O
have	O
2	O
keys	O
:	O
a1	O
and	O
a2	O
.	O
</s>
<s>
All	O
values	O
in	O
the	O
leftmost	O
subtree	B-Application
will	O
be	O
less	O
than	O
a1	O
,	O
all	O
values	O
in	O
the	O
middle	O
subtree	B-Application
will	O
be	O
between	O
a1	O
and	O
a2	O
,	O
and	O
all	O
values	O
in	O
the	O
rightmost	O
subtree	B-Application
will	O
be	O
greater	O
than	O
a2	O
.	O
</s>
<s>
Internal	O
nodes	B-Data_Structure
(	O
also	O
known	O
as	O
inner	B-Application
nodes	I-Application
)	O
are	O
all	O
nodes	B-Data_Structure
except	O
for	O
leaf	B-Application
nodes	I-Application
and	O
the	O
root	B-Application
node	I-Application
.	O
</s>
<s>
The	O
relationship	O
between	O
U	O
and	O
L	O
implies	O
that	O
two	O
half-full	O
nodes	B-Data_Structure
can	O
be	O
joined	O
to	O
make	O
a	O
legal	O
node	O
,	O
and	O
one	O
full	O
node	O
can	O
be	O
split	O
into	O
two	O
legal	O
nodes	B-Data_Structure
(	O
if	O
there	O
's	O
room	O
to	O
push	O
one	O
element	O
up	O
into	O
the	O
parent	O
)	O
.	O
</s>
<s>
These	O
properties	O
make	O
it	O
possible	O
to	O
delete	O
and	O
insert	O
new	O
values	O
into	O
a	O
B-tree	B-Architecture
and	O
adjust	O
the	O
tree	O
to	O
preserve	O
the	O
B-tree	B-Architecture
properties	O
.	O
</s>
<s>
The	O
root	B-Application
node	I-Application
's	O
number	O
of	O
children	O
has	O
the	O
same	O
upper	O
limit	O
as	O
internal	O
nodes	B-Data_Structure
,	O
but	O
has	O
no	O
lower	O
limit	O
.	O
</s>
<s>
In	O
Knuth	O
's	O
terminology	O
,	O
the	O
"	O
leaf	O
"	O
nodes	B-Data_Structure
are	O
the	O
actual	O
data	O
objects	O
/	O
chunks	O
.	O
</s>
<s>
The	O
internal	O
nodes	B-Data_Structure
that	O
are	O
one	O
level	O
above	O
these	O
leaves	O
are	O
what	O
would	O
be	O
called	O
the	O
"	O
leaves	O
"	O
by	O
other	O
authors	O
:	O
these	O
nodes	B-Data_Structure
only	O
store	O
keys	O
(	O
at	O
most	O
m-1	O
,	O
and	O
at	O
least	O
m/2	O
-1	O
if	O
they	O
are	O
not	O
the	O
root	O
)	O
and	O
pointers	O
(	O
one	O
for	O
each	O
key	O
)	O
to	O
nodes	B-Data_Structure
carrying	O
the	O
data	O
objects	O
/	O
chunks	O
.	O
</s>
<s>
A	O
B-tree	B-Architecture
of	O
depth	O
n+1	O
can	O
hold	O
about	O
U	O
times	O
as	O
many	O
items	O
as	O
a	O
B-tree	B-Architecture
of	O
depth	O
n	O
,	O
but	O
the	O
cost	O
of	O
search	O
,	O
insert	O
,	O
and	O
delete	O
operations	O
grows	O
with	O
the	O
depth	O
of	O
the	O
tree	O
.	O
</s>
<s>
As	O
with	O
any	O
balanced	B-Data_Structure
tree	I-Data_Structure
,	O
the	O
cost	O
grows	O
much	O
more	O
slowly	O
than	O
the	O
number	O
of	O
elements	O
.	O
</s>
<s>
Some	O
balanced	B-Data_Structure
trees	I-Data_Structure
store	O
values	O
only	O
at	O
leaf	B-Application
nodes	I-Application
,	O
and	O
use	O
different	O
kinds	O
of	O
nodes	B-Data_Structure
for	O
leaf	B-Application
nodes	I-Application
and	O
internal	O
nodes	B-Data_Structure
.	O
</s>
<s>
B-trees	B-Architecture
keep	O
values	O
in	O
every	O
node	O
in	O
the	O
tree	O
except	O
leaf	B-Application
nodes	I-Application
.	O
</s>
<s>
The	O
literature	O
on	O
B-trees	B-Architecture
is	O
not	O
uniform	O
in	O
its	O
terminology	O
.	O
</s>
<s>
Bayer	O
and	O
McCreight	O
(	O
1972	O
)	O
,	O
Comer	O
(	O
1979	O
)	O
,	O
and	O
others	O
define	O
the	O
order	O
of	O
B-tree	B-Architecture
as	O
the	O
minimum	O
number	O
of	O
keys	O
in	O
a	O
non-root	O
node	O
.	O
</s>
<s>
An	O
order	O
3	O
B-tree	B-Architecture
might	O
hold	O
a	O
maximum	O
of	O
6	O
keys	O
or	O
a	O
maximum	O
of	O
7	O
keys	O
.	O
</s>
<s>
Those	O
choices	O
are	O
not	O
fundamental	O
to	O
the	O
idea	O
of	O
a	O
B-tree	B-Architecture
.	O
</s>
<s>
In	O
B-trees	B-Architecture
,	O
internal	O
(	O
non-leaf	B-Data_Structure
)	O
nodes	B-Data_Structure
can	O
have	O
a	O
variable	O
number	O
of	O
child	O
nodes	B-Data_Structure
within	O
some	O
pre-defined	O
range	O
.	O
</s>
<s>
When	O
data	O
is	O
inserted	O
or	O
removed	O
from	O
a	O
node	O
,	O
its	O
number	O
of	O
child	O
nodes	B-Data_Structure
changes	O
.	O
</s>
<s>
In	O
order	O
to	O
maintain	O
the	O
pre-defined	O
range	O
,	O
internal	O
nodes	B-Data_Structure
may	O
be	O
joined	O
or	O
split	O
.	O
</s>
<s>
Because	O
a	O
range	O
of	O
child	O
nodes	B-Data_Structure
is	O
permitted	O
,	O
B-trees	B-Architecture
do	O
not	O
need	O
re-balancing	O
as	O
frequently	O
as	O
other	O
self-balancing	O
search	O
trees	O
,	O
but	O
may	O
waste	O
some	O
space	O
,	O
since	O
nodes	B-Data_Structure
are	O
not	O
entirely	O
full	O
.	O
</s>
<s>
The	O
lower	O
and	O
upper	O
bounds	O
on	O
the	O
number	O
of	O
child	O
nodes	B-Data_Structure
are	O
typically	O
fixed	O
for	O
a	O
particular	O
implementation	O
.	O
</s>
<s>
For	O
example	O
,	O
in	O
a	O
2	B-Data_Structure
–	I-Data_Structure
3	I-Data_Structure
tree	I-Data_Structure
(	O
sometimes	O
referred	O
to	O
as	O
a	O
2	O
–	O
3	O
B-tree	B-Architecture
)	O
,	O
each	O
internal	O
node	O
may	O
have	O
only	O
2	O
or	O
3	O
child	O
nodes	B-Data_Structure
.	O
</s>
<s>
Each	O
internal	O
node	O
of	O
a	O
B-tree	B-Architecture
contains	O
a	O
number	O
of	O
keys	O
.	O
</s>
<s>
The	O
keys	O
act	O
as	O
separation	O
values	O
which	O
divide	O
its	O
subtrees	B-Application
.	O
</s>
<s>
For	O
example	O
,	O
if	O
an	O
internal	O
node	O
has	O
3	O
child	O
nodes	B-Data_Structure
(	O
or	O
subtrees	B-Application
)	O
then	O
it	O
must	O
have	O
2	O
keys	O
:	O
and	O
.	O
</s>
<s>
All	O
values	O
in	O
the	O
leftmost	O
subtree	B-Application
will	O
be	O
less	O
than	O
,	O
all	O
values	O
in	O
the	O
middle	O
subtree	B-Application
will	O
be	O
between	O
and	O
,	O
and	O
all	O
values	O
in	O
the	O
rightmost	O
subtree	B-Application
will	O
be	O
greater	O
than	O
.	O
</s>
<s>
Usually	O
,	O
the	O
number	O
of	O
keys	O
is	O
chosen	O
to	O
vary	O
between	O
and	O
,	O
where	O
is	O
the	O
minimum	O
number	O
of	O
keys	O
,	O
and	O
is	O
the	O
minimum	O
degree	O
or	O
branching	B-Data_Structure
factor	I-Data_Structure
of	O
the	O
tree	O
.	O
</s>
<s>
The	O
factor	O
of	O
2	O
will	O
guarantee	O
that	O
nodes	B-Data_Structure
can	O
be	O
split	O
or	O
combined	O
.	O
</s>
<s>
If	O
an	O
internal	O
node	O
has	O
keys	O
,	O
then	O
adding	O
a	O
key	O
to	O
that	O
node	O
can	O
be	O
accomplished	O
by	O
splitting	O
the	O
hypothetical	O
key	O
node	O
into	O
two	O
key	O
nodes	B-Data_Structure
and	O
moving	O
the	O
key	O
that	O
would	O
have	O
been	O
in	O
the	O
middle	O
to	O
the	O
parent	B-Application
node	I-Application
.	O
</s>
<s>
The	O
number	O
of	O
branches	O
(	O
or	O
child	O
nodes	B-Data_Structure
)	O
from	O
a	O
node	O
will	O
be	O
one	O
more	O
than	O
the	O
number	O
of	O
keys	O
stored	O
in	O
the	O
node	O
.	O
</s>
<s>
In	O
a	O
2	O
–	O
3	O
B-tree	B-Architecture
,	O
the	O
internal	O
nodes	B-Data_Structure
will	O
store	O
either	O
one	O
key	O
(	O
with	O
two	O
child	O
nodes	B-Data_Structure
)	O
or	O
two	O
keys	O
(	O
with	O
three	O
child	O
nodes	B-Data_Structure
)	O
.	O
</s>
<s>
A	O
B-tree	B-Architecture
is	O
sometimes	O
described	O
with	O
the	O
parameters	O
—	O
or	O
simply	O
with	O
the	O
highest	O
branching	O
order	O
,	O
.	O
</s>
<s>
A	O
B-tree	B-Architecture
is	O
kept	O
balanced	O
after	O
insertion	O
by	O
splitting	O
a	O
would-be	O
overfilled	O
node	O
,	O
of	O
keys	O
,	O
into	O
two	O
-key	O
siblings	O
and	O
inserting	O
the	O
mid-value	O
key	O
into	O
the	O
parent	O
.	O
</s>
<s>
Similarly	O
,	O
a	O
B-tree	B-Architecture
is	O
kept	O
balanced	O
after	O
deletion	O
by	O
merging	O
or	O
redistributing	O
keys	O
among	O
siblings	O
to	O
maintain	O
the	O
-key	O
minimum	O
for	O
non-root	O
nodes	O
.	O
</s>
<s>
This	O
depth	O
will	O
increase	O
slowly	O
as	O
elements	O
are	O
added	O
to	O
the	O
tree	O
,	O
but	O
an	O
increase	O
in	O
the	O
overall	O
depth	O
is	O
infrequent	O
,	O
and	O
results	O
in	O
all	O
leaf	B-Application
nodes	I-Application
being	O
one	O
more	O
node	O
farther	O
away	O
from	O
the	O
root	O
.	O
</s>
<s>
B-trees	B-Architecture
have	O
substantial	O
advantages	O
over	O
alternative	O
implementations	O
when	O
the	O
time	O
to	O
access	O
the	O
data	O
of	O
a	O
node	O
greatly	O
exceeds	O
the	O
time	O
spent	O
processing	O
that	O
data	O
,	O
because	O
then	O
the	O
cost	O
of	O
accessing	O
the	O
node	O
may	O
be	O
amortized	O
over	O
multiple	O
operations	O
within	O
the	O
node	O
.	O
</s>
<s>
This	O
usually	O
occurs	O
when	O
the	O
node	O
data	O
are	O
in	O
secondary	O
storage	O
such	O
as	O
disk	B-Device
drives	I-Device
.	O
</s>
<s>
The	O
maximum	O
number	O
of	O
child	O
nodes	B-Data_Structure
depends	O
on	O
the	O
information	O
that	O
must	O
be	O
stored	O
for	O
each	O
child	O
node	O
and	O
the	O
size	O
of	O
a	O
full	O
disk	B-General_Concept
block	I-General_Concept
or	O
an	O
analogous	O
size	O
in	O
secondary	O
storage	O
.	O
</s>
<s>
While	O
2	O
–	O
3	O
B-trees	B-Architecture
are	O
easier	O
to	O
explain	O
,	O
practical	O
B-trees	B-Architecture
using	O
secondary	O
storage	O
need	O
a	O
large	O
number	O
of	O
child	O
nodes	B-Data_Structure
to	O
improve	O
performance	O
.	O
</s>
<s>
The	O
term	O
B-tree	B-Architecture
may	O
refer	O
to	O
a	O
specific	O
design	O
or	O
it	O
may	O
refer	O
to	O
a	O
general	O
class	O
of	O
designs	O
.	O
</s>
<s>
In	O
the	O
narrow	O
sense	O
,	O
a	O
B-tree	B-Architecture
stores	O
keys	O
in	O
its	O
internal	O
nodes	B-Data_Structure
but	O
need	O
not	O
store	O
those	O
keys	O
in	O
the	O
records	O
at	O
the	O
leaves	O
.	O
</s>
<s>
In	O
the	O
B+	O
tree	O
,	O
copies	O
of	O
the	O
keys	O
are	O
stored	O
in	O
the	O
internal	O
nodes	B-Data_Structure
;	O
the	O
keys	O
and	O
records	O
are	O
stored	O
in	O
leaves	O
;	O
in	O
addition	O
,	O
a	O
leaf	B-Data_Structure
node	I-Data_Structure
may	O
include	O
a	O
pointer	O
to	O
the	O
next	O
leaf	B-Data_Structure
node	I-Data_Structure
to	O
speed	O
sequential	O
access	O
.	O
</s>
<s>
The	O
B*	O
tree	O
balances	O
more	O
neighboring	O
internal	O
nodes	B-Data_Structure
to	O
keep	O
the	O
internal	O
nodes	B-Data_Structure
more	O
densely	O
packed	O
.	O
</s>
<s>
As	O
the	O
most	O
costly	O
part	O
of	O
operation	O
of	O
inserting	O
the	O
node	O
in	O
B-tree	B-Architecture
is	O
splitting	O
the	O
node	O
,	O
B*	O
-trees	O
are	O
created	O
to	O
postpone	O
splitting	O
operation	O
as	O
long	O
as	O
they	O
can	O
.	O
</s>
<s>
This	O
spill	O
operation	O
is	O
less	O
costly	O
to	O
do	O
than	O
split	O
,	O
because	O
it	O
requires	O
only	O
shifting	O
the	O
keys	O
between	O
existing	O
nodes	B-Data_Structure
,	O
not	O
allocating	O
memory	O
for	O
a	O
new	O
one	O
.	O
</s>
<s>
However	O
,	O
if	O
the	O
node	O
is	O
full	O
(	O
it	O
has	O
keys	O
,	O
where	O
is	O
the	O
order	O
of	O
the	O
tree	O
as	O
maximum	O
number	O
of	O
pointers	O
to	O
subtrees	B-Application
from	O
one	O
node	O
)	O
,	O
it	O
needs	O
to	O
be	O
checked	O
whether	O
the	O
right	O
sibling	O
exists	O
and	O
has	O
some	O
free	O
space	O
.	O
</s>
<s>
If	O
the	O
right	O
sibling	O
has	O
keys	O
,	O
then	O
keys	O
are	O
redistributed	O
between	O
the	O
two	O
sibling	O
nodes	B-Data_Structure
as	O
evenly	O
as	O
possible	O
.	O
</s>
<s>
For	O
this	O
purpose	O
,	O
keys	O
from	O
the	O
current	O
node	O
,	O
the	O
new	O
key	O
inserted	O
,	O
one	O
key	O
from	O
the	O
parent	B-Application
node	I-Application
and	O
keys	O
from	O
the	O
sibling	O
node	O
are	O
seen	O
as	O
an	O
ordered	O
array	O
of	O
keys	O
.	O
</s>
<s>
When	O
both	O
the	O
sibling	O
nodes	B-Data_Structure
are	O
full	O
,	O
then	O
the	O
two	O
nodes	B-Data_Structure
(	O
current	O
node	O
and	O
a	O
sibling	O
)	O
are	O
split	O
into	O
three	O
and	O
one	O
more	O
key	O
is	O
shifted	O
up	O
the	O
tree	O
,	O
to	O
the	O
parent	B-Application
node	I-Application
.	O
</s>
<s>
If	O
the	O
parent	O
is	O
full	O
,	O
then	O
spill/split	O
operation	O
propagates	O
towards	O
the	O
root	B-Application
node	I-Application
.	O
</s>
<s>
Deleting	O
nodes	B-Data_Structure
is	O
somewhat	O
more	O
complex	O
than	O
inserting	O
however	O
.	O
</s>
<s>
B-trees	B-Architecture
can	O
be	O
turned	O
into	O
order	B-Algorithm
statistic	I-Algorithm
trees	I-Algorithm
to	O
allow	O
rapid	O
searches	O
for	O
the	O
Nth	O
record	O
in	O
key	O
order	O
,	O
or	O
counting	O
the	O
number	O
of	O
records	O
between	O
any	O
two	O
records	O
,	O
and	O
various	O
other	O
related	O
operations	O
.	O
</s>
<s>
Large	O
databases	O
have	O
historically	O
been	O
kept	O
on	O
disk	B-Device
drives	I-Device
.	O
</s>
<s>
The	O
time	O
wo	O
n't	O
be	O
that	O
bad	O
because	O
individual	O
records	O
are	O
grouped	O
together	O
in	O
a	O
disk	B-General_Concept
block	I-General_Concept
.	O
</s>
<s>
A	O
disk	B-General_Concept
block	I-General_Concept
might	O
be	O
16	O
kilobytes	O
.	O
</s>
<s>
Once	O
the	O
disk	O
head	O
is	O
in	O
position	O
,	O
one	O
or	O
more	O
disk	B-General_Concept
blocks	I-General_Concept
can	O
be	O
read	O
with	O
little	O
delay	O
.	O
</s>
<s>
With	O
100	O
records	O
per	O
block	O
,	O
the	O
last	O
6	O
or	O
so	O
comparisons	O
do	O
n't	O
need	O
to	O
do	O
any	O
disk	O
reads	O
—	O
the	O
comparisons	O
are	O
all	O
within	O
the	O
last	O
disk	B-General_Concept
block	I-General_Concept
read	O
.	O
</s>
<s>
A	O
B-tree	B-Architecture
index	B-Data_Structure
creates	O
a	O
multi-level	O
tree	O
structure	O
that	O
breaks	O
a	O
database	O
down	O
into	O
fixed-size	O
blocks	O
or	O
pages	O
.	O
</s>
<s>
A	O
significant	O
improvement	O
in	O
performance	O
can	O
be	O
made	O
with	O
a	O
B-tree	B-Architecture
index	B-Data_Structure
.	O
</s>
<s>
Because	O
each	O
node	O
(	O
or	O
internal	O
page	O
)	O
can	O
have	O
more	O
than	O
two	O
children	O
,	O
a	O
B-tree	B-Architecture
index	B-Data_Structure
will	O
usually	O
have	O
a	O
shorter	O
height	O
(	O
the	O
distance	O
from	O
the	O
root	O
to	O
the	O
farthest	O
leaf	O
)	O
than	O
a	O
Binary	B-Language
Search	I-Language
Tree	I-Language
.	O
</s>
<s>
That	O
can	O
be	O
improved	O
substantially	O
by	O
creating	O
an	O
auxiliary	O
index	B-Data_Structure
that	O
contains	O
the	O
first	O
record	O
in	O
each	O
disk	B-General_Concept
block	I-General_Concept
(	O
sometimes	O
called	O
a	O
sparse	B-Data_Structure
index	I-Data_Structure
)	O
.	O
</s>
<s>
This	O
auxiliary	O
index	B-Data_Structure
would	O
be	O
1%	O
of	O
the	O
size	O
of	O
the	O
original	O
database	O
,	O
but	O
it	O
can	O
be	O
searched	O
more	O
quickly	O
.	O
</s>
<s>
Finding	O
an	O
entry	O
in	O
the	O
auxiliary	O
index	B-Data_Structure
would	O
tell	O
us	O
which	O
block	O
to	O
search	O
in	O
the	O
main	O
database	O
;	O
after	O
searching	O
the	O
auxiliary	O
index	B-Data_Structure
,	O
we	O
would	O
have	O
to	O
search	O
only	O
that	O
one	O
block	O
of	O
the	O
main	O
database	O
—	O
at	O
a	O
cost	O
of	O
one	O
more	O
disk	O
read	O
.	O
</s>
<s>
The	O
index	B-Data_Structure
would	O
hold	O
10,000	O
entries	O
,	O
so	O
it	O
would	O
take	O
at	O
most	O
14	O
comparisons	O
.	O
</s>
<s>
Like	O
the	O
main	O
database	O
,	O
the	O
last	O
six	O
or	O
so	O
comparisons	O
in	O
the	O
auxiliary	O
index	B-Data_Structure
would	O
be	O
on	O
the	O
same	O
disk	B-General_Concept
block	I-General_Concept
.	O
</s>
<s>
The	O
index	B-Data_Structure
could	O
be	O
searched	O
in	O
about	O
eight	O
disk	O
reads	O
,	O
and	O
the	O
desired	O
record	O
could	O
be	O
accessed	O
in	O
9	O
disk	O
reads	O
.	O
</s>
<s>
The	O
trick	O
of	O
creating	O
an	O
auxiliary	O
index	B-Data_Structure
can	O
be	O
repeated	O
to	O
make	O
an	O
auxiliary	O
index	B-Data_Structure
to	O
the	O
auxiliary	O
index	B-Data_Structure
.	O
</s>
<s>
That	O
would	O
make	O
an	O
aux-aux	O
index	B-Data_Structure
that	O
would	O
need	O
only	O
100	O
entries	O
and	O
would	O
fit	O
in	O
one	O
disk	B-General_Concept
block	I-General_Concept
.	O
</s>
<s>
Instead	O
of	O
reading	O
14	O
disk	B-General_Concept
blocks	I-General_Concept
to	O
find	O
the	O
desired	O
record	O
,	O
we	O
only	O
need	O
to	O
read	O
3	O
blocks	O
.	O
</s>
<s>
This	O
blocking	O
is	O
the	O
core	O
idea	O
behind	O
the	O
creation	O
of	O
the	O
B-tree	B-Architecture
,	O
where	O
the	O
disk	B-General_Concept
blocks	I-General_Concept
fill-out	O
a	O
hierarchy	O
of	O
levels	O
to	O
make	O
up	O
the	O
index	B-Data_Structure
.	O
</s>
<s>
Reading	O
and	O
searching	O
the	O
first	O
(	O
and	O
only	O
)	O
block	O
of	O
the	O
aux-aux	O
index	B-Data_Structure
which	O
is	O
the	O
root	O
of	O
the	O
tree	O
identifies	O
the	O
relevant	O
block	O
in	O
aux-index	O
in	O
the	O
level	O
below	O
.	O
</s>
<s>
Reading	O
and	O
searching	O
that	O
aux-index	O
block	O
identifies	O
the	O
relevant	O
block	O
to	O
read	O
,	O
until	O
the	O
final	O
level	O
,	O
known	O
as	O
the	O
leaf	O
level	O
,	O
identifies	O
a	O
record	O
in	O
the	O
main	O
database	O
.	O
</s>
<s>
In	O
practice	O
,	O
if	O
the	O
main	O
database	O
is	O
being	O
frequently	O
searched	O
,	O
the	O
aux-aux	O
index	B-Data_Structure
and	O
much	O
of	O
the	O
aux	O
index	B-Data_Structure
may	O
reside	O
in	O
a	O
disk	B-General_Concept
cache	I-General_Concept
,	O
so	O
they	O
would	O
not	O
incur	O
a	O
disk	O
read	O
.	O
</s>
<s>
The	O
B-tree	B-Architecture
remains	O
the	O
standard	O
index	B-Data_Structure
implementation	O
in	O
almost	O
all	O
relational	B-Application
databases	I-Application
,	O
and	O
many	O
nonrelational	O
databases	O
use	O
them	O
too	O
.	O
</s>
<s>
If	O
the	O
database	O
does	O
not	O
change	O
,	O
then	O
compiling	O
the	O
index	B-Data_Structure
is	O
simple	O
to	O
do	O
,	O
and	O
the	O
index	B-Data_Structure
need	O
never	O
be	O
changed	O
.	O
</s>
<s>
If	O
there	O
are	O
changes	O
,	O
then	O
managing	O
the	O
database	O
and	O
its	O
index	B-Data_Structure
becomes	O
more	O
complicated	O
.	O
</s>
<s>
The	O
index	B-Data_Structure
can	O
stay	O
the	O
same	O
,	O
and	O
the	O
record	O
can	O
just	O
be	O
marked	O
as	O
deleted	O
.	O
</s>
<s>
If	O
there	O
are	O
a	O
large	O
number	O
of	O
lazy	B-Algorithm
deletions	I-Algorithm
,	O
then	O
searching	O
and	O
storage	O
become	O
less	O
efficient	O
.	O
</s>
<s>
Insertions	O
can	O
be	O
very	O
slow	O
in	O
a	O
sorted	O
sequential	B-Application
file	I-Application
because	O
room	O
for	O
the	O
inserted	O
record	O
must	O
be	O
made	O
.	O
</s>
<s>
Alternatively	O
,	O
some	O
out-of-sequence	O
disk	B-General_Concept
blocks	I-General_Concept
may	O
be	O
used	O
.	O
</s>
<s>
The	O
B-tree	B-Architecture
uses	O
all	O
of	O
the	O
ideas	O
described	O
above	O
.	O
</s>
<s>
In	O
particular	O
,	O
a	O
B-tree	B-Architecture
:	O
</s>
<s>
In	O
addition	O
,	O
a	O
B-tree	B-Architecture
minimizes	O
waste	O
by	O
making	O
sure	O
the	O
interior	B-Application
nodes	I-Application
are	O
at	O
least	O
half	O
full	O
.	O
</s>
<s>
A	O
B-tree	B-Architecture
can	O
handle	O
an	O
arbitrary	O
number	O
of	O
insertions	O
and	O
deletions	O
.	O
</s>
<s>
Let	O
be	O
the	O
height	O
of	O
the	O
classic	O
B-tree	B-Architecture
(	O
see	O
for	O
the	O
tree	O
height	O
definition	O
)	O
.	O
</s>
<s>
It	O
can	O
be	O
shown	O
(	O
by	O
induction	O
for	O
example	O
)	O
that	O
a	O
B-tree	B-Architecture
of	O
height	O
h	O
with	O
all	O
its	O
nodes	B-Data_Structure
completely	O
filled	O
has	O
entries	O
.	O
</s>
<s>
the	O
minimum	O
height	O
)	O
of	O
a	O
B-tree	B-Architecture
is	O
:	O
</s>
<s>
For	O
an	O
ordinary	O
B-tree	B-Architecture
,	O
</s>
<s>
Searching	O
is	O
similar	O
to	O
searching	O
a	O
binary	B-Language
search	I-Language
tree	I-Language
.	O
</s>
<s>
At	O
each	O
level	O
,	O
the	O
search	O
reduces	O
its	O
field	O
of	O
view	O
to	O
the	O
child	O
pointer	O
(	O
subtree	B-Application
)	O
whose	O
range	O
includes	O
the	O
search	O
value	O
.	O
</s>
<s>
A	O
subtree	B-Application
's	O
range	O
is	O
defined	O
by	O
the	O
values	O
,	O
or	O
keys	O
,	O
contained	O
in	O
its	O
parent	B-Application
node	I-Application
.	O
</s>
<s>
Binary	O
search	O
is	O
typically	O
(	O
but	O
not	O
necessarily	O
)	O
used	O
within	O
nodes	B-Data_Structure
to	O
find	O
the	O
separation	O
values	O
and	O
child	O
tree	O
of	O
interest	O
.	O
</s>
<s>
All	O
insertions	O
start	O
at	O
a	O
leaf	B-Data_Structure
node	I-Data_Structure
.	O
</s>
<s>
To	O
insert	O
a	O
new	O
element	O
,	O
search	O
the	O
tree	O
to	O
find	O
the	O
leaf	B-Data_Structure
node	I-Data_Structure
where	O
the	O
new	O
element	O
should	O
be	O
added	O
.	O
</s>
<s>
Otherwise	O
the	O
node	O
is	O
full	O
,	O
evenly	O
split	O
it	O
into	O
two	O
nodes	B-Data_Structure
so	O
:	O
</s>
<s>
If	O
the	O
splitting	O
goes	O
all	O
the	O
way	O
up	O
to	O
the	O
root	O
,	O
it	O
creates	O
a	O
new	O
root	O
with	O
a	O
single	O
separator	O
value	O
and	O
two	O
children	O
,	O
which	O
is	O
why	O
the	O
lower	O
bound	O
on	O
the	O
size	O
of	O
internal	O
nodes	B-Data_Structure
does	O
not	O
apply	O
to	O
the	O
root	O
.	O
</s>
<s>
So	O
,	O
it	O
must	O
be	O
possible	O
to	O
divide	O
the	O
maximum	O
number	O
U−1	O
of	O
elements	O
into	O
two	O
legal	O
nodes	B-Data_Structure
.	O
</s>
<s>
If	O
this	O
number	O
is	O
odd	O
,	O
then	O
U	O
=	O
2L	O
and	O
one	O
of	O
the	O
new	O
nodes	B-Data_Structure
contains	O
(	O
U−2	O
)	O
/2	O
=	O
L−1	O
elements	O
,	O
and	O
hence	O
is	O
a	O
legal	O
node	O
,	O
and	O
the	O
other	O
contains	O
one	O
more	O
element	O
,	O
and	O
hence	O
it	O
is	O
legal	O
too	O
.	O
</s>
<s>
An	O
alternative	O
algorithm	O
supports	O
a	O
single	O
pass	O
down	O
the	O
tree	O
from	O
the	O
root	O
to	O
the	O
node	O
where	O
the	O
insertion	O
will	O
take	O
place	O
,	O
splitting	O
any	O
full	O
nodes	B-Data_Structure
encountered	O
on	O
the	O
way	O
preemptively	O
.	O
</s>
<s>
This	O
prevents	O
the	O
need	O
to	O
recall	O
the	O
parent	B-Application
nodes	I-Application
into	O
memory	O
,	O
which	O
may	O
be	O
expensive	O
if	O
the	O
nodes	B-Data_Structure
are	O
on	O
secondary	O
storage	O
.	O
</s>
<s>
However	O
,	O
to	O
use	O
this	O
algorithm	O
,	O
we	O
must	O
be	O
able	O
to	O
send	O
one	O
element	O
to	O
the	O
parent	O
and	O
split	O
the	O
remaining	O
U−2	O
elements	O
into	O
two	O
legal	O
nodes	B-Data_Structure
,	O
without	O
adding	O
a	O
new	O
element	O
.	O
</s>
<s>
This	O
requires	O
U	O
=	O
2L	O
rather	O
than	O
U	O
=	O
2L−1	O
,	O
which	O
accounts	O
for	O
why	O
some	O
textbooks	O
impose	O
this	O
requirement	O
in	O
defining	O
B-trees	B-Architecture
.	O
</s>
<s>
There	O
are	O
two	O
popular	O
strategies	O
for	O
deletion	O
from	O
a	O
B-tree	B-Architecture
.	O
</s>
<s>
If	O
the	O
value	O
is	O
in	O
a	O
leaf	B-Data_Structure
node	I-Data_Structure
,	O
simply	O
delete	O
it	O
from	O
the	O
node	O
.	O
</s>
<s>
Each	O
element	O
in	O
an	O
internal	O
node	O
acts	O
as	O
a	O
separation	O
value	O
for	O
two	O
subtrees	B-Application
,	O
therefore	O
we	O
need	O
to	O
find	O
a	O
replacement	O
for	O
separation	O
.	O
</s>
<s>
Note	O
that	O
the	O
largest	O
element	O
in	O
the	O
left	O
subtree	B-Application
is	O
still	O
less	O
than	O
the	O
separator	O
.	O
</s>
<s>
Likewise	O
,	O
the	O
smallest	O
element	O
in	O
the	O
right	O
subtree	B-Application
is	O
still	O
greater	O
than	O
the	O
separator	O
.	O
</s>
<s>
Both	O
of	O
those	O
elements	O
are	O
in	O
leaf	B-Application
nodes	I-Application
,	O
and	O
either	O
one	O
can	O
be	O
the	O
new	O
separator	O
for	O
the	O
two	O
subtrees	B-Application
.	O
</s>
<s>
Choose	O
a	O
new	O
separator	O
(	O
either	O
the	O
largest	O
element	O
in	O
the	O
left	O
subtree	B-Application
or	O
the	O
smallest	O
element	O
in	O
the	O
right	O
subtree	B-Application
)	O
,	O
remove	O
it	O
from	O
the	O
leaf	B-Data_Structure
node	I-Data_Structure
it	O
is	O
in	O
,	O
and	O
replace	O
the	O
element	O
to	O
be	O
deleted	O
with	O
the	O
new	O
separator	O
.	O
</s>
<s>
The	O
previous	O
step	O
deleted	O
an	O
element	O
(	O
the	O
new	O
separator	O
)	O
from	O
a	O
leaf	B-Data_Structure
node	I-Data_Structure
.	O
</s>
<s>
If	O
that	O
leaf	B-Data_Structure
node	I-Data_Structure
is	O
now	O
deficient	O
(	O
has	O
fewer	O
than	O
the	O
required	O
number	O
of	O
nodes	B-Data_Structure
)	O
,	O
then	O
rebalance	O
the	O
tree	O
starting	O
from	O
the	O
leaf	B-Data_Structure
node	I-Data_Structure
.	O
</s>
<s>
If	O
deleting	O
an	O
element	O
from	O
a	O
node	O
has	O
brought	O
it	O
under	O
the	O
minimum	O
size	O
,	O
then	O
some	O
elements	O
must	O
be	O
redistributed	O
to	O
bring	O
all	O
nodes	B-Data_Structure
up	O
to	O
the	O
minimum	O
.	O
</s>
<s>
Usually	O
,	O
the	O
redistribution	O
involves	O
moving	O
an	O
element	O
from	O
a	O
sibling	O
node	O
that	O
has	O
more	O
than	O
the	O
minimum	O
number	O
of	O
nodes	B-Data_Structure
.	O
</s>
<s>
A	O
common	O
special	O
case	O
is	O
adding	O
a	O
large	O
amount	O
of	O
pre-sorted	O
data	O
into	O
an	O
initially	O
empty	O
B-tree	B-Architecture
.	O
</s>
<s>
While	O
it	O
is	O
quite	O
possible	O
to	O
simply	O
perform	O
a	O
series	O
of	O
successive	O
inserts	O
,	O
inserting	O
sorted	O
data	O
results	O
in	O
a	O
tree	O
composed	O
almost	O
entirely	O
of	O
half-full	O
nodes	B-Data_Structure
.	O
</s>
<s>
Instead	O
,	O
a	O
special	O
"	O
bulk	O
loading	O
"	O
algorithm	O
can	O
be	O
used	O
to	O
produce	O
a	O
more	O
efficient	O
tree	O
with	O
a	O
higher	O
branching	B-Data_Structure
factor	I-Data_Structure
.	O
</s>
<s>
When	O
bulk	O
loading	O
,	O
we	O
take	O
advantage	O
of	O
this	O
,	O
and	O
instead	O
of	O
splitting	O
overfull	O
nodes	B-Data_Structure
evenly	O
,	O
split	O
them	O
as	O
unevenly	O
as	O
possible	O
:	O
leave	O
the	O
left	O
node	O
completely	O
full	O
and	O
create	O
a	O
right	O
node	O
with	O
zero	O
keys	O
and	O
one	O
child	O
(	O
in	O
violation	O
of	O
the	O
usual	O
B-tree	B-Architecture
rules	O
)	O
.	O
</s>
<s>
At	O
the	O
end	O
of	O
bulk	O
loading	O
,	O
the	O
tree	O
is	O
composed	O
almost	O
entirely	O
of	O
completely	O
full	O
nodes	B-Data_Structure
;	O
only	O
the	O
rightmost	O
node	O
on	O
each	O
level	O
may	O
be	O
less	O
than	O
full	O
.	O
</s>
<s>
Because	O
those	O
nodes	B-Data_Structure
may	O
also	O
be	O
less	O
than	O
half	O
full	O
,	O
to	O
re-establish	O
the	O
normal	O
B-tree	B-Architecture
rules	O
,	O
combine	O
such	O
nodes	B-Data_Structure
with	O
their	O
(	O
guaranteed	O
full	O
)	O
left	O
siblings	O
and	O
divide	O
the	O
keys	O
to	O
produce	O
two	O
nodes	B-Data_Structure
at	O
least	O
half	O
full	O
.	O
</s>
<s>
In	O
addition	O
to	O
its	O
use	O
in	O
databases	O
,	O
the	O
B-tree	B-Architecture
(	O
or	O
)	O
is	O
also	O
used	O
in	O
filesystems	B-Application
to	O
allow	O
quick	O
random	O
access	O
to	O
an	O
arbitrary	O
block	O
in	O
a	O
particular	O
file	O
.	O
</s>
<s>
The	O
basic	O
problem	O
is	O
turning	O
the	O
file	O
block	O
address	O
into	O
a	O
disk	B-General_Concept
block	I-General_Concept
address	O
.	O
</s>
<s>
The	O
file	O
can	O
then	O
be	O
allocated	O
as	O
contiguous	O
disk	B-General_Concept
blocks	I-General_Concept
.	O
</s>
<s>
In	O
that	O
case	O
,	O
to	O
convert	O
the	O
file	O
block	O
address	O
into	O
a	O
disk	B-General_Concept
block	I-General_Concept
address	O
,	O
the	O
operating	O
system	O
simply	O
adds	O
the	O
file	O
block	O
address	O
to	O
the	O
address	O
of	O
the	O
first	O
disk	B-General_Concept
block	I-General_Concept
constituting	O
the	O
file	O
.	O
</s>
<s>
The	O
resulting	O
disk	B-General_Concept
blocks	I-General_Concept
may	O
not	O
be	O
contiguous	O
,	O
so	O
mapping	O
logical	O
blocks	O
to	O
physical	O
blocks	O
is	O
more	O
involved	O
.	O
</s>
<s>
MS-DOS	B-Application
,	O
for	O
example	O
,	O
used	O
a	O
simple	O
File	B-Application
Allocation	I-Application
Table	I-Application
(	O
FAT	O
)	O
.	O
</s>
<s>
The	O
FAT	O
has	O
an	O
entry	O
for	O
each	O
disk	B-General_Concept
block	I-General_Concept
,	O
and	O
that	O
entry	O
identifies	O
whether	O
its	O
block	O
is	O
used	O
by	O
a	O
file	O
and	O
if	O
so	O
,	O
which	O
block	O
(	O
if	O
any	O
)	O
is	O
the	O
next	O
disk	B-General_Concept
block	I-General_Concept
of	O
the	O
same	O
file	O
.	O
</s>
<s>
So	O
,	O
the	O
allocation	O
of	O
each	O
file	O
is	O
represented	O
as	O
a	O
linked	B-Data_Structure
list	I-Data_Structure
in	O
the	O
table	O
.	O
</s>
<s>
In	O
order	O
to	O
find	O
the	O
disk	O
address	O
of	O
file	O
block	O
,	O
the	O
operating	O
system	O
(	O
or	O
disk	O
utility	O
)	O
must	O
sequentially	O
follow	O
the	O
file	O
's	O
linked	B-Data_Structure
list	I-Data_Structure
in	O
the	O
FAT	O
.	O
</s>
<s>
Worse	O
,	O
to	O
find	O
a	O
free	O
disk	B-General_Concept
block	I-General_Concept
,	O
it	O
must	O
sequentially	O
scan	O
the	O
FAT	O
.	O
</s>
<s>
For	O
MS-DOS	B-Application
,	O
that	O
was	O
not	O
a	O
huge	O
penalty	O
because	O
the	O
disks	O
and	O
files	O
were	O
small	O
and	O
the	O
FAT	O
had	O
few	O
entries	O
and	O
relatively	O
short	O
file	O
chains	O
.	O
</s>
<s>
In	O
the	O
FAT12	B-Application
filesystem	B-Application
(	O
used	O
on	O
floppy	O
disks	O
and	O
early	O
hard	B-Device
disks	I-Device
)	O
,	O
there	O
were	O
no	O
more	O
than	O
4,080	O
entries	O
,	O
and	O
the	O
FAT	O
would	O
usually	O
be	O
resident	O
in	O
memory	O
.	O
</s>
<s>
TOPS-20	B-Operating_System
(	O
and	O
possibly	O
TENEX	B-Operating_System
)	O
used	O
a	O
0	O
to	O
2	O
level	O
tree	O
that	O
has	O
similarities	O
to	O
a	O
B-tree	B-Architecture
.	O
</s>
<s>
A	O
disk	B-General_Concept
block	I-General_Concept
was	O
512	O
36-bit	O
words	O
.	O
</s>
<s>
If	O
the	O
file	O
fit	O
in	O
a	O
512	O
(	O
29	O
)	O
word	O
block	O
,	O
then	O
the	O
file	O
directory	O
would	O
point	O
to	O
that	O
physical	O
disk	B-General_Concept
block	I-General_Concept
.	O
</s>
<s>
If	O
the	O
file	O
fit	O
in	O
218	O
words	O
,	O
then	O
the	O
directory	O
would	O
point	O
to	O
an	O
aux	O
index	B-Data_Structure
;	O
the	O
512	O
words	O
of	O
that	O
index	B-Data_Structure
would	O
either	O
be	O
NULL	O
(	O
the	O
block	O
is	O
n't	O
allocated	O
)	O
or	O
point	O
to	O
the	O
physical	O
address	O
of	O
the	O
block	O
.	O
</s>
<s>
If	O
the	O
file	O
fit	O
in	O
227	O
words	O
,	O
then	O
the	O
directory	O
would	O
point	O
to	O
a	O
block	O
holding	O
an	O
aux-aux	O
index	B-Data_Structure
;	O
each	O
entry	O
would	O
either	O
be	O
NULL	O
or	O
point	O
to	O
an	O
aux	O
index	B-Data_Structure
.	O
</s>
<s>
Consequently	O
,	O
the	O
physical	O
disk	B-General_Concept
block	I-General_Concept
for	O
a	O
227	O
word	O
file	O
could	O
be	O
located	O
in	O
two	O
disk	O
reads	O
and	O
read	O
on	O
the	O
third	O
.	O
</s>
<s>
Apple	O
's	O
filesystem	B-Application
HFS+	B-Application
and	O
APFS	B-Application
,	O
Microsoft	O
's	O
NTFS	B-Application
,	O
AIX	O
(	O
jfs2	O
)	O
and	O
some	O
Linux	B-Application
filesystems	B-Application
,	O
such	O
as	O
btrfs	B-Operating_System
and	O
Ext4	B-Application
,	O
use	O
B-trees	B-Architecture
.	O
</s>
<s>
B*	O
-trees	O
are	O
used	O
in	O
the	O
HFS	B-Application
and	O
Reiser4	B-Application
file	B-Application
systems	I-Application
.	O
</s>
<s>
DragonFly	B-Application
BSD	I-Application
's	O
HAMMER	B-Application
file	I-Application
system	I-Application
uses	O
a	O
modified	O
B+	O
-tree	O
.	O
</s>
<s>
A	O
B-tree	B-Architecture
grows	O
slower	O
with	O
growing	O
data	O
amount	O
,	O
than	O
the	O
linearity	O
of	O
a	O
linked	B-Data_Structure
list	I-Data_Structure
.	O
</s>
<s>
Compared	O
to	O
a	O
skip	O
list	O
,	O
both	O
structures	O
have	O
the	O
same	O
performance	O
,	O
but	O
the	O
B-tree	B-Architecture
scales	O
better	O
for	O
growing	O
n	O
.	O
A	O
T-tree	B-Data_Structure
,	O
for	O
main	B-General_Concept
memory	I-General_Concept
database	I-General_Concept
systems	I-General_Concept
,	O
is	O
similar	O
but	O
more	O
compact	O
.	O
</s>
<s>
This	O
maximizes	O
access	O
concurrency	O
by	O
multiple	O
users	O
,	O
an	O
important	O
consideration	O
for	O
databases	O
and/or	O
other	O
B-tree-based	O
ISAM	B-Application
storage	O
methods	O
.	O
</s>
<s>
The	O
cost	O
associated	O
with	O
this	O
improvement	O
is	O
that	O
empty	O
pages	O
cannot	O
be	O
removed	O
from	O
the	O
btree	B-Architecture
during	O
normal	O
operations	O
.	O
</s>
<s>
The	O
technique	O
accesses	O
the	O
tree	O
'	O
upwards	O
 '	O
for	O
both	O
searches	O
and	O
updates	O
by	O
means	O
of	O
additional	O
in-memory	B-General_Concept
indexes	O
that	O
point	O
at	O
the	O
blocks	O
in	O
each	O
level	O
in	O
the	O
block	O
cache	O
.	O
</s>
<s>
Since	O
B-trees	B-Architecture
are	O
similar	O
in	O
structure	O
to	O
red-black	O
trees	O
,	O
parallel	O
algorithms	O
for	O
red-black	O
trees	O
can	O
be	O
applied	O
to	O
B-trees	B-Architecture
as	O
well	O
.	O
</s>
