<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
a	O
ball	B-Data_Structure
tree	I-Data_Structure
,	O
balltree	B-Data_Structure
or	O
metric	O
tree	O
,	O
is	O
a	O
space	B-Algorithm
partitioning	I-Algorithm
data	B-General_Concept
structure	I-General_Concept
for	O
organizing	O
points	O
in	O
a	O
multi-dimensional	O
space	O
.	O
</s>
<s>
A	O
ball	B-Data_Structure
tree	I-Data_Structure
partitions	O
data	O
points	O
into	O
a	O
nested	O
set	O
of	O
balls	O
.	O
</s>
<s>
The	O
resulting	O
data	B-General_Concept
structure	I-General_Concept
has	O
characteristics	O
that	O
make	O
it	O
useful	O
for	O
a	O
number	O
of	O
applications	O
,	O
most	O
notably	O
nearest	B-Algorithm
neighbor	I-Algorithm
search	I-Algorithm
.	O
</s>
<s>
A	O
ball	B-Data_Structure
tree	I-Data_Structure
is	O
a	O
binary	O
tree	O
in	O
which	O
every	O
node	O
defines	O
a	O
D-dimensional	O
ball	O
containing	O
a	O
subset	O
of	O
the	O
points	O
to	O
be	O
searched	O
.	O
</s>
<s>
Each	O
internal	O
node	O
of	O
the	O
tree	O
partitions	O
the	O
data	O
points	O
into	O
two	O
disjoint	B-Algorithm
sets	I-Algorithm
which	O
are	O
associated	O
with	O
different	O
balls	O
.	O
</s>
<s>
Ball-trees	B-Data_Structure
are	O
related	O
to	O
the	O
M-tree	B-Data_Structure
,	O
but	O
only	O
support	O
binary	O
splits	O
,	O
whereas	O
in	O
the	O
M-tree	B-Data_Structure
each	O
level	O
splits	O
to	O
fold	O
,	O
thus	O
leading	O
to	O
a	O
shallower	O
tree	O
structure	O
,	O
therefore	O
need	O
fewer	O
distance	O
computations	O
,	O
which	O
usually	O
yields	O
faster	O
queries	O
.	O
</s>
<s>
Furthermore	O
,	O
M-trees	B-Data_Structure
can	O
better	O
be	O
stored	O
on	O
disk	O
,	O
which	O
is	O
organized	O
in	O
pages	B-General_Concept
.	O
</s>
<s>
The	O
M-tree	B-Data_Structure
also	O
keeps	O
the	O
distances	O
from	O
the	O
parent	O
node	O
precomputed	O
to	O
speed	O
up	O
queries	O
.	O
</s>
<s>
Vantage-point	B-Data_Structure
trees	I-Data_Structure
are	O
also	O
similar	O
,	O
but	O
they	O
binary	O
split	O
into	O
one	O
ball	O
,	O
and	O
the	O
remaining	O
data	O
,	O
instead	O
of	O
using	O
two	O
balls	O
.	O
</s>
<s>
A	O
number	O
of	O
ball	B-Data_Structure
tree	I-Data_Structure
construction	O
algorithms	O
are	O
available	O
.	O
</s>
<s>
The	O
simplest	O
such	O
procedure	O
is	O
termed	O
the	O
"	O
k-d	O
Construction	O
Algorithm	O
"	O
,	O
by	O
analogy	O
with	O
the	O
process	O
used	O
to	O
construct	O
k-d	B-Data_Structure
trees	I-Data_Structure
.	O
</s>
<s>
This	O
is	O
an	O
offline	B-Algorithm
algorithm	I-Algorithm
,	O
that	O
is	O
,	O
an	O
algorithm	O
that	O
operates	O
on	O
the	O
entire	O
data	O
set	O
at	O
once	O
.	O
</s>
<s>
output	O
:	O
B	O
,	O
the	O
root	O
of	O
a	O
constructed	O
ball	B-Data_Structure
tree	I-Data_Structure
.	O
</s>
<s>
An	O
important	O
application	O
of	O
ball	B-Data_Structure
trees	I-Data_Structure
is	O
expediting	O
nearest	B-Algorithm
neighbor	I-Algorithm
search	I-Algorithm
queries	O
,	O
in	O
which	O
the	O
objective	O
is	O
to	O
find	O
the	O
k	O
points	O
in	O
the	O
tree	O
that	O
are	O
closest	O
to	O
a	O
given	O
test	O
point	O
by	O
some	O
distance	O
metric	O
(	O
e.g.	O
</s>
<s>
A	O
simple	O
search	O
algorithm	O
,	O
sometimes	O
called	O
KNS1	O
,	O
exploits	O
the	O
distance	O
property	O
of	O
the	O
ball	B-Data_Structure
tree	I-Data_Structure
.	O
</s>
<s>
In	O
particular	O
,	O
if	O
the	O
algorithm	O
is	O
searching	O
the	O
data	B-General_Concept
structure	I-General_Concept
with	O
a	O
test	O
point	O
t	O
,	O
and	O
has	O
already	O
seen	O
some	O
point	O
p	O
that	O
is	O
closest	O
to	O
t	O
among	O
the	O
points	O
encountered	O
so	O
far	O
,	O
then	O
any	O
subtree	O
whose	O
ball	O
is	O
further	O
from	O
t	O
than	O
p	O
can	O
be	O
ignored	O
for	O
the	O
rest	O
of	O
the	O
search	O
.	O
</s>
<s>
The	O
ball	B-Data_Structure
tree	I-Data_Structure
nearest-neighbor	O
algorithm	O
examines	O
nodes	O
in	O
depth-first	O
order	O
,	O
starting	O
at	O
the	O
root	O
.	O
</s>
<s>
maintains	O
a	O
max-first	O
priority	B-Application
queue	I-Application
(	O
often	O
implemented	O
with	O
a	O
heap	B-Application
)	O
,	O
denoted	O
Q	O
here	O
,	O
of	O
the	O
k	O
nearest	O
points	O
encountered	O
so	O
far	O
.	O
</s>
<s>
At	O
each	O
node	O
B	O
,	O
it	O
may	O
perform	O
one	O
of	O
three	O
operations	O
,	O
before	O
finally	O
returning	O
an	O
updated	O
version	O
of	O
the	O
priority	B-Application
queue	I-Application
:	O
</s>
<s>
However	O
,	O
the	O
best	O
nearest-neighbor	O
data	B-General_Concept
structure	I-General_Concept
for	O
a	O
given	O
application	O
will	O
depend	O
on	O
the	O
dimensionality	O
,	O
number	O
of	O
data	O
points	O
,	O
and	O
underlying	O
structure	O
of	O
the	O
data	O
.	O
</s>
