<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
an	O
interval	B-Data_Structure
tree	I-Data_Structure
is	O
a	O
tree	B-Application
data	I-Application
structure	I-Application
to	O
hold	O
intervals	O
.	O
</s>
<s>
A	O
similar	O
data	O
structure	O
is	O
the	O
segment	B-Architecture
tree	I-Architecture
.	O
</s>
<s>
Since	O
a	O
query	O
may	O
return	O
all	O
intervals	O
,	O
for	O
example	O
if	O
the	O
query	O
is	O
a	O
large	O
interval	O
intersecting	O
all	O
intervals	O
in	O
the	O
collection	O
,	O
this	O
is	O
asymptotically	B-General_Concept
optimal	I-General_Concept
;	O
however	O
,	O
we	O
can	O
do	O
better	O
by	O
considering	O
output-sensitive	B-Language
algorithms	I-Language
,	O
where	O
the	O
runtime	O
is	O
expressed	O
in	O
terms	O
of	O
,	O
the	O
number	O
of	O
intervals	O
produced	O
by	O
the	O
query	O
.	O
</s>
<s>
Interval	B-Data_Structure
trees	I-Data_Structure
have	O
a	O
query	O
time	O
of	O
and	O
an	O
initial	O
creation	O
time	O
of	O
,	O
while	O
limiting	O
memory	O
consumption	O
to	O
.	O
</s>
<s>
After	O
creation	O
,	O
interval	B-Data_Structure
trees	I-Data_Structure
may	O
be	O
dynamic	O
,	O
allowing	O
efficient	O
insertion	O
and	O
deletion	O
of	O
an	O
interval	O
in	O
time	O
.	O
</s>
<s>
In	O
a	O
simple	O
case	O
,	O
the	O
intervals	O
do	O
not	O
overlap	O
and	O
they	O
can	O
be	O
inserted	O
into	O
a	O
simple	O
binary	B-Language
search	I-Language
tree	I-Language
and	O
queried	O
in	O
time	O
.	O
</s>
<s>
Interval	B-Data_Structure
trees	I-Data_Structure
solve	O
this	O
problem	O
.	O
</s>
<s>
This	O
article	O
describes	O
two	O
alternative	O
designs	O
for	O
an	O
interval	B-Data_Structure
tree	I-Data_Structure
,	O
dubbed	O
the	O
centered	O
interval	B-Data_Structure
tree	I-Data_Structure
and	O
the	O
augmented	O
tree	O
.	O
</s>
<s>
The	O
intervals	O
in	O
that	O
overlap	O
the	O
center	O
point	O
are	O
stored	O
in	O
a	O
separate	O
data	O
structure	O
linked	O
to	O
the	O
node	O
in	O
the	O
interval	B-Data_Structure
tree	I-Data_Structure
.	O
</s>
<s>
The	O
interval	B-Data_Structure
tree	I-Data_Structure
data	O
structure	O
can	O
be	O
generalized	O
to	O
a	O
higher	O
dimension	O
with	O
identical	O
query	O
and	O
construction	O
time	O
and	O
space	O
.	O
</s>
<s>
First	O
,	O
a	O
range	B-Data_Structure
tree	I-Data_Structure
in	O
dimensions	O
is	O
constructed	O
that	O
allows	O
efficient	O
retrieval	O
of	O
all	O
intervals	O
with	O
beginning	O
and	O
end	O
points	O
inside	O
the	O
query	O
region	O
.	O
</s>
<s>
To	O
find	O
these	O
overlaps	O
,	O
interval	B-Data_Structure
trees	I-Data_Structure
are	O
created	O
,	O
and	O
one	O
axis	O
intersecting	O
is	O
queried	O
for	O
each	O
.	O
</s>
<s>
For	O
example	O
,	O
in	O
two	O
dimensions	O
,	O
the	O
bottom	O
of	O
the	O
square	O
(	O
or	O
any	O
other	O
horizontal	O
line	O
intersecting	O
)	O
would	O
be	O
queried	O
against	O
the	O
interval	B-Data_Structure
tree	I-Data_Structure
constructed	O
for	O
the	O
horizontal	O
axis	O
.	O
</s>
<s>
Likewise	O
,	O
the	O
left	O
(	O
or	O
any	O
other	O
vertical	O
line	O
intersecting	O
)	O
would	O
be	O
queried	O
against	O
the	O
interval	B-Data_Structure
tree	I-Data_Structure
constructed	O
on	O
the	O
vertical	O
axis	O
.	O
</s>
<s>
Each	O
interval	B-Data_Structure
tree	I-Data_Structure
also	O
needs	O
an	O
addition	O
for	O
higher	O
dimensions	O
.	O
</s>
<s>
Instead	O
of	O
two	O
sorted	O
lists	O
of	O
points	O
as	O
was	O
used	O
in	O
the	O
one-dimensional	O
case	O
,	O
a	O
range	B-Data_Structure
tree	I-Data_Structure
is	O
constructed	O
.	O
</s>
<s>
Since	O
each	O
node	O
stores	O
the	O
intervals	O
that	O
overlap	O
it	O
,	O
with	O
all	O
intervals	O
completely	O
to	O
the	O
left	O
of	O
its	O
center	O
point	O
in	O
the	O
left	O
subtree	B-Application
,	O
similarly	O
for	O
the	O
right	O
subtree	B-Application
,	O
it	O
follows	O
that	O
each	O
interval	O
is	O
stored	O
in	O
the	O
node	O
closest	O
to	O
the	O
root	O
from	O
the	O
set	O
of	O
nodes	O
whose	O
center	O
point	O
it	O
overlaps	O
.	O
</s>
<s>
Normal	O
deletion	O
operations	O
in	O
a	O
binary	O
tree	O
(	O
for	O
the	O
case	O
where	O
the	O
node	O
being	O
deleted	O
has	O
two	O
children	O
)	O
involve	O
promoting	O
a	O
node	O
further	O
from	O
the	O
leaf	O
to	O
the	O
position	O
of	O
the	O
node	O
being	O
deleted	O
(	O
usually	O
the	O
leftmost	O
child	O
of	O
the	O
right	O
subtree	B-Application
,	O
or	O
the	O
rightmost	O
child	O
of	O
the	O
left	O
subtree	B-Application
)	O
.	O
</s>
<s>
An	O
augmented	O
tree	O
can	O
be	O
built	O
from	O
a	O
simple	O
ordered	O
tree	O
,	O
for	O
example	O
a	O
binary	B-Language
search	I-Language
tree	I-Language
or	O
self-balancing	B-Data_Structure
binary	I-Data_Structure
search	I-Data_Structure
tree	I-Data_Structure
,	O
ordered	O
by	O
the	O
'	O
low	O
 '	O
values	O
of	O
the	O
intervals	O
.	O
</s>
<s>
If	O
there	O
are	O
any	O
tree	B-Data_Structure
rotations	I-Data_Structure
during	O
insertion	O
and	O
deletion	O
,	O
the	O
affected	O
nodes	O
may	O
need	O
updating	O
as	O
well	O
.	O
</s>
<s>
Alternately	O
,	O
at	O
the	O
rate	O
of	O
memory	O
,	O
membership	O
queries	O
in	O
expected	O
constant	O
time	O
can	O
be	O
implemented	O
with	O
a	O
hash	O
table	O
,	O
updated	O
in	O
lockstep	O
with	O
the	O
interval	B-Data_Structure
tree	I-Data_Structure
.	O
</s>
<s>
This	O
approach	O
effectively	O
converts	O
the	O
data	O
structure	O
from	O
an	O
augmented	O
binary	O
tree	O
to	O
an	O
augmented	O
kd-tree	B-Data_Structure
,	O
thus	O
significantly	O
complicating	O
the	O
balancing	O
algorithms	O
for	O
insertions	O
and	O
deletions	O
.	O
</s>
<s>
A	O
simpler	O
solution	O
is	O
to	O
use	O
nested	O
interval	B-Data_Structure
trees	I-Data_Structure
.	O
</s>
<s>
Now	O
,	O
for	O
each	O
node	O
in	O
the	O
tree	O
,	O
add	O
another	O
interval	B-Data_Structure
tree	I-Data_Structure
on	O
the	O
x-ranges	O
,	O
for	O
all	O
elements	O
whose	O
y-range	O
is	O
the	O
same	O
as	O
that	O
node	O
's	O
y-range	O
.	O
</s>
<s>
This	O
structure	O
is	O
usually	O
of	O
negligible	O
size	O
,	O
consisting	O
only	O
of	O
a	O
pointer	O
to	O
the	O
root	B-Application
node	I-Application
,	O
and	O
possibly	O
the	O
number	O
of	O
nodes	O
and	O
the	O
depth	O
of	O
the	O
tree	O
.	O
</s>
<s>
A	O
medial	O
-	O
or	O
length-oriented	O
tree	O
is	O
similar	O
to	O
an	O
augmented	O
tree	O
,	O
but	O
symmetrical	O
,	O
with	O
the	O
binary	B-Language
search	I-Language
tree	I-Language
ordered	O
by	O
the	O
medial	O
points	O
of	O
the	O
intervals	O
.	O
</s>
<s>
There	O
is	O
a	O
maximum-oriented	O
binary	B-Application
heap	I-Application
in	O
every	O
node	O
,	O
ordered	O
by	O
the	O
length	O
of	O
the	O
interval	O
(	O
or	O
half	O
of	O
the	O
length	O
)	O
.	O
</s>
<s>
Also	O
we	O
store	O
the	O
minimum	O
and	O
maximum	O
possible	O
value	O
of	O
the	O
subtree	B-Application
in	O
each	O
node	O
(	O
thus	O
the	O
symmetry	O
)	O
.	O
</s>
<s>
Adding	O
new	O
intervals	O
to	O
the	O
tree	O
is	O
the	O
same	O
as	O
for	O
a	O
binary	B-Language
search	I-Language
tree	I-Language
using	O
the	O
medial	O
value	O
as	O
the	O
key	O
.	O
</s>
<s>
We	O
push	O
onto	O
the	O
binary	B-Application
heap	I-Application
associated	O
with	O
the	O
node	O
,	O
and	O
update	O
the	O
minimum	O
and	O
maximum	O
possible	O
values	O
associated	O
with	O
all	O
higher	O
nodes	O
.	O
</s>
<s>
Starting	O
with	O
root	B-Application
node	I-Application
,	O
in	O
each	O
node	O
,	O
first	O
we	O
check	O
if	O
it	O
is	O
possible	O
that	O
our	O
query	O
interval	O
overlaps	O
with	O
the	O
node	O
subtree	B-Application
using	O
minimum	O
and	O
maximum	O
values	O
of	O
node	O
(	O
if	O
it	O
is	O
not	O
,	O
we	O
do	O
n't	O
continue	O
for	O
this	O
node	O
)	O
.	O
</s>
<s>
This	O
algorithm	O
is	O
expected	O
to	O
be	O
faster	O
than	O
a	O
traditional	O
interval	B-Data_Structure
tree	I-Data_Structure
(	O
augmented	O
tree	O
)	O
for	O
search	O
operations	O
.	O
</s>
