<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
a	O
range	B-Data_Structure
tree	I-Data_Structure
is	O
an	O
ordered	B-Application
tree	I-Application
data	I-Application
structure	I-Application
to	O
hold	O
a	O
list	O
of	O
points	O
.	O
</s>
<s>
It	O
allows	O
all	O
points	O
within	O
a	O
given	O
range	O
to	O
be	O
reported	B-General_Concept
efficiently	O
,	O
and	O
is	O
typically	O
used	O
in	O
two	O
or	O
higher	O
dimensions	O
.	O
</s>
<s>
Range	B-Data_Structure
trees	I-Data_Structure
were	O
introduced	O
by	O
Jon	O
Louis	O
Bentley	O
in	O
1979	O
.	O
</s>
<s>
Similar	O
data	B-General_Concept
structures	I-General_Concept
were	O
discovered	O
independently	O
by	O
Lueker	O
,	O
Lee	O
and	O
Wong	O
,	O
and	O
Willard	O
.	O
</s>
<s>
The	O
range	B-Data_Structure
tree	I-Data_Structure
is	O
an	O
alternative	O
to	O
the	O
k-d	B-Data_Structure
tree	I-Data_Structure
.	O
</s>
<s>
Compared	O
to	O
k-d	B-Data_Structure
trees	I-Data_Structure
,	O
range	B-Data_Structure
trees	I-Data_Structure
offer	O
faster	O
query	O
times	O
of	O
(	O
in	O
Big	O
O	O
notation	O
)	O
but	O
worse	O
storage	O
of	O
,	O
where	O
n	O
is	O
the	O
number	O
of	O
points	O
stored	O
in	O
the	O
tree	O
,	O
d	O
is	O
the	O
dimension	O
of	O
each	O
point	O
and	O
k	O
is	O
the	O
number	O
of	O
points	O
reported	B-General_Concept
by	O
a	O
given	O
query	O
.	O
</s>
<s>
A	O
range	B-Data_Structure
tree	I-Data_Structure
on	O
a	O
set	O
of	O
1-dimensional	O
points	O
is	O
a	O
balanced	O
binary	B-Language
search	I-Language
tree	I-Language
on	O
those	O
points	O
.	O
</s>
<s>
The	O
points	O
stored	O
in	O
the	O
tree	O
are	O
stored	O
in	O
the	O
leaves	O
of	O
the	O
tree	O
;	O
each	O
internal	O
node	O
stores	O
the	O
largest	O
value	O
of	O
its	O
left	O
subtree	B-Application
.	O
</s>
<s>
A	O
range	B-Data_Structure
tree	I-Data_Structure
on	O
a	O
set	O
of	O
points	O
in	O
d-dimensions	O
is	O
a	O
recursively	O
defined	O
multi-level	O
binary	B-Language
search	I-Language
tree	I-Language
.	O
</s>
<s>
Each	O
level	O
of	O
the	O
data	B-General_Concept
structure	I-General_Concept
is	O
a	O
binary	B-Language
search	I-Language
tree	I-Language
on	O
one	O
of	O
the	O
d-dimensions	O
.	O
</s>
<s>
The	O
first	O
level	O
is	O
a	O
binary	B-Language
search	I-Language
tree	I-Language
on	O
the	O
first	O
of	O
the	O
d-coordinates	O
.	O
</s>
<s>
Each	O
vertex	O
v	O
of	O
this	O
tree	O
contains	O
an	O
associated	O
structure	O
that	O
is	O
a	O
(	O
d−1	O
)	O
-dimensional	O
range	B-Data_Structure
tree	I-Data_Structure
on	O
the	O
last	O
(	O
d−1	O
)	O
-coordinates	O
of	O
the	O
points	O
stored	O
in	O
the	O
subtree	B-Application
of	O
v	O
.	O
</s>
<s>
A	O
1-dimensional	O
range	B-Data_Structure
tree	I-Data_Structure
on	O
a	O
set	O
of	O
n	O
points	O
is	O
a	O
binary	B-Language
search	I-Language
tree	I-Language
,	O
which	O
can	O
be	O
constructed	O
in	O
time	O
.	O
</s>
<s>
Range	B-Data_Structure
trees	I-Data_Structure
in	O
higher	O
dimensions	O
are	O
constructed	O
recursively	O
by	O
constructing	O
a	O
balanced	O
binary	B-Language
search	I-Language
tree	I-Language
on	O
the	O
first	O
coordinate	O
of	O
the	O
points	O
,	O
and	O
then	O
,	O
for	O
each	O
vertex	O
v	O
in	O
this	O
tree	O
,	O
constructing	O
a	O
(	O
d−1	O
)	O
-dimensional	O
range	B-Data_Structure
tree	I-Data_Structure
on	O
the	O
points	O
contained	O
in	O
the	O
subtree	B-Application
of	O
v	O
.	O
Constructing	O
a	O
range	B-Data_Structure
tree	I-Data_Structure
this	O
way	O
would	O
require	O
time	O
.	O
</s>
<s>
This	O
construction	O
time	O
can	O
be	O
improved	O
for	O
2-dimensional	O
range	B-Data_Structure
trees	I-Data_Structure
to	O
.	O
</s>
<s>
Otherwise	O
,	O
construct	O
the	O
associated	O
structure	O
of	O
S	O
,	O
a	O
1-dimensional	O
range	B-Data_Structure
tree	I-Data_Structure
on	O
the	O
y-coordinates	O
of	O
the	O
points	O
in	O
S	O
.	O
Let	O
xm	O
be	O
the	O
median	O
x-coordinate	O
of	O
the	O
points	O
.	O
</s>
<s>
Recursively	O
construct	O
vL	O
,	O
a	O
2-dimensional	O
range	B-Data_Structure
tree	I-Data_Structure
on	O
SL	O
,	O
and	O
vR	O
,	O
a	O
2-dimensional	O
range	B-Data_Structure
tree	I-Data_Structure
on	O
SR	O
.	O
</s>
<s>
If	O
we	O
sort	O
the	O
points	O
by	O
their	O
y-coordinates	O
at	O
the	O
start	O
of	O
the	O
algorithm	O
,	O
and	O
maintain	O
this	O
ordering	O
when	O
splitting	O
the	O
points	O
by	O
their	O
x-coordinate	O
,	O
we	O
can	O
construct	O
the	O
associated	O
structures	O
of	O
each	O
subtree	B-Application
in	O
linear	O
time	O
.	O
</s>
<s>
This	O
reduces	O
the	O
time	O
to	O
construct	O
a	O
2-dimensional	O
range	B-Data_Structure
tree	I-Data_Structure
to	O
,	O
and	O
also	O
reduces	O
the	O
time	O
to	O
construct	O
a	O
d-dimensional	O
range	B-Data_Structure
tree	I-Data_Structure
to	O
.	O
</s>
<s>
A	O
range	B-Data_Structure
query	I-Data_Structure
on	O
a	O
range	B-Data_Structure
tree	I-Data_Structure
reports	O
the	O
set	O
of	O
points	O
that	O
lie	O
inside	O
a	O
given	O
interval	O
.	O
</s>
<s>
For	O
every	O
vertex	O
v	O
in	O
the	O
search	O
path	O
from	O
vsplit	O
to	O
x1	O
,	O
if	O
the	O
value	O
stored	O
at	O
v	O
is	O
greater	O
than	O
x1	O
,	O
report	O
every	O
point	O
in	O
the	O
right-subtree	O
of	O
v	O
.	O
If	O
v	O
is	O
a	O
leaf	O
,	O
report	O
the	O
value	O
stored	O
at	O
v	O
if	O
it	O
is	O
inside	O
the	O
query	O
interval	O
.	O
</s>
<s>
Similarly	O
,	O
reporting	O
all	O
of	O
the	O
points	O
stored	O
in	O
the	O
left-subtrees	O
of	O
the	O
vertices	O
with	O
values	O
less	O
than	O
x2	O
along	O
the	O
search	O
path	O
from	O
vsplit	O
to	O
x2	O
,	O
and	O
report	O
the	O
leaf	O
of	O
this	O
path	O
if	O
it	O
lies	O
within	O
the	O
query	O
interval	O
.	O
</s>
<s>
Since	O
the	O
range	B-Data_Structure
tree	I-Data_Structure
is	O
a	O
balanced	O
binary	O
tree	O
,	O
the	O
search	O
paths	O
to	O
x1	O
and	O
x2	O
have	O
length	O
.	O
</s>
<s>
Reporting	O
all	O
of	O
the	O
points	O
stored	O
in	O
the	O
subtree	B-Application
of	O
a	O
vertex	O
can	O
be	O
done	O
in	O
linear	O
time	O
using	O
any	O
tree	B-Algorithm
traversal	I-Algorithm
algorithm	O
.	O
</s>
<s>
It	O
follows	O
that	O
the	O
time	O
to	O
perform	O
a	O
range	B-Data_Structure
query	I-Data_Structure
is	O
,	O
where	O
k	O
is	O
the	O
number	O
of	O
points	O
in	O
the	O
query	O
interval	O
.	O
</s>
<s>
Range	B-Data_Structure
queries	I-Data_Structure
in	O
d-dimensions	O
are	O
similar	O
.	O
</s>
<s>
Instead	O
of	O
reporting	O
all	O
of	O
the	O
points	O
stored	O
in	O
the	O
subtrees	B-Application
of	O
the	O
search	O
paths	O
,	O
perform	O
a	O
(	O
d−1	O
)	O
-dimensional	O
range	B-Data_Structure
query	I-Data_Structure
on	O
the	O
associated	O
structure	O
of	O
each	O
subtree	B-Application
.	O
</s>
<s>
Eventually	O
,	O
a	O
1-dimensional	O
range	B-Data_Structure
query	I-Data_Structure
will	O
be	O
performed	O
and	O
the	O
correct	O
points	O
will	O
be	O
reported	B-General_Concept
.	O
</s>
<s>
Since	O
a	O
d-dimensional	O
query	O
consists	O
of	O
(	O
d−1	O
)	O
-dimensional	O
range	B-Data_Structure
queries	I-Data_Structure
,	O
it	O
follows	O
that	O
the	O
time	O
required	O
to	O
perform	O
a	O
d-dimensional	O
range	B-Data_Structure
query	I-Data_Structure
is	O
,	O
where	O
k	O
is	O
the	O
number	O
of	O
points	O
in	O
the	O
query	O
interval	O
.	O
</s>
<s>
This	O
can	O
be	O
reduced	O
to	O
using	O
a	O
variant	O
of	O
fractional	B-Data_Structure
cascading	I-Data_Structure
.	O
</s>
