<s>
The	O
PH-tree	B-Data_Structure
is	O
a	O
tree	B-Application
data	I-Application
structure	I-Application
used	O
for	O
spatial	O
indexing	O
of	O
multi-dimensional	O
data	O
(	O
keys	O
)	O
such	O
as	O
geographical	O
coordinates	O
,	O
points	O
,	O
feature	B-Algorithm
vectors	I-Algorithm
,	O
rectangles	O
or	O
bounding	B-Algorithm
boxes	I-Algorithm
.	O
</s>
<s>
The	O
PH-tree	B-Data_Structure
is	O
space	O
partitioning	O
index	O
with	O
a	O
structure	O
similar	O
to	O
that	O
of	O
a	O
quadtree	B-Data_Structure
or	O
octree	B-Data_Structure
.	O
</s>
<s>
However	O
,	O
unlike	O
quadtrees	B-Data_Structure
,	O
it	O
uses	O
a	O
splitting	O
policy	O
based	O
on	O
tries	B-General_Concept
and	O
similar	O
to	O
Crit	B-Data_Structure
bit	I-Data_Structure
trees	I-Data_Structure
that	O
is	O
based	O
on	O
the	O
bit-representation	O
of	O
the	O
keys	O
.	O
</s>
<s>
The	O
basic	O
PH-tree	B-Data_Structure
is	O
a	O
spatial	O
index	O
that	O
maps	B-Application
keys	O
,	O
which	O
are	O
-dimensional	O
vectors	O
with	O
integers	O
,	O
to	O
user	O
defined	O
values	O
.	O
</s>
<s>
The	O
PH-tree	B-Data_Structure
is	O
a	O
multi-dimensional	O
generalization	O
of	O
a	O
Crit	B-Data_Structure
bit	I-Data_Structure
tree	I-Data_Structure
in	O
the	O
sense	O
that	O
a	O
Crit	B-Data_Structure
bit	I-Data_Structure
tree	I-Data_Structure
is	O
equivalent	O
to	O
a	O
PH-tree	B-Data_Structure
with	O
-dimensional	O
keys	O
.	O
</s>
<s>
Like	O
the	O
Crit	B-Data_Structure
bit	I-Data_Structure
tree	I-Data_Structure
,	O
and	O
unlike	O
most	O
other	O
spatial	O
indexes	O
,	O
the	O
PH-tree	B-Data_Structure
is	O
a	O
map	B-Application
rather	O
than	O
a	O
multimap	B-Language
.	O
</s>
<s>
A	O
-dimensional	O
PH-tree	B-Data_Structure
is	O
a	O
tree	O
of	O
nodes	O
where	O
each	O
node	O
partitions	O
space	O
by	O
subdividing	O
it	O
into	O
quadrants	O
(	O
see	O
below	O
for	O
how	O
potentially	O
large	O
nodes	O
scales	O
with	O
high	O
dimensional	O
data	O
)	O
.	O
</s>
<s>
Each	O
node	O
has	O
at	O
least	O
two	O
entries	O
,	O
otherwise	O
it	O
is	O
merged	O
with	O
the	O
parent	B-Application
node	I-Application
.	O
</s>
<s>
Some	O
other	O
structural	O
properties	O
of	O
PH-trees	B-Data_Structure
are	O
:	O
</s>
<s>
They	O
are	O
inherently	O
unbalanced	B-Data_Structure
but	O
imbalance	O
is	O
limited	O
due	O
to	O
their	O
depth	O
being	O
limited	O
to	O
the	O
bit	O
width	O
of	O
the	O
keys	O
,	O
e.g.	O
</s>
<s>
Similar	O
to	O
most	O
quadtrees	B-Data_Structure
,	O
the	O
PH-tree	B-Data_Structure
is	O
a	O
hierarchy	O
of	O
nodes	O
where	O
every	O
node	O
splits	O
the	O
space	O
in	O
all	O
dimensions	O
.	O
</s>
<s>
The	O
PH-tree	B-Data_Structure
uses	O
the	O
bits	O
of	O
the	O
multi-dimensional	O
keys	O
to	O
determine	O
their	O
position	O
in	O
the	O
tree	O
.	O
</s>
<s>
The	O
ordering	O
of	O
the	O
entries	O
in	O
a	O
node	O
always	O
follows	O
Z-ordering	B-Algorithm
.	O
</s>
<s>
Another	O
solution	O
is	O
to	O
store	O
entries	O
in	O
a	O
sorted	O
collection	O
,	O
such	O
as	O
dynamic	B-Data_Structure
arrays	I-Data_Structure
and/or	O
B-trees	B-Architecture
.	O
</s>
<s>
The	O
original	O
implementation	O
aimed	O
for	O
minimal	O
memory	O
consumption	O
by	O
switching	O
between	O
fixed	O
and	O
dynamic	B-Data_Structure
array	I-Data_Structure
representation	O
depending	O
on	O
which	O
uses	O
less	O
memory	O
.	O
</s>
<s>
Other	O
implementations	O
do	O
not	O
switch	O
dynamically	O
but	O
use	O
fixed	O
arrays	O
for	O
,	O
dynamic	B-Data_Structure
arrays	I-Data_Structure
for	O
and	O
B-trees	B-Architecture
for	O
high	O
dimensional	O
data	O
.	O
</s>
<s>
If	O
the	O
tree	O
is	O
implemented	O
as	O
multi-map	O
with	O
a	O
collection	O
as	O
the	O
node	O
's	O
entry	O
,	O
the	O
new	O
value	O
is	O
added	O
to	O
that	O
collection	O
.	O
</s>
<s>
The	O
remaining	O
entry	O
is	O
moved	O
to	O
the	O
parent	B-Application
node	I-Application
.	O
</s>
<s>
A	O
trivial	O
implementation	O
traverses	O
all	O
entries	O
in	O
a	O
node	O
(	O
starting	O
with	O
the	O
root	B-Application
node	I-Application
)	O
and	O
if	O
an	O
entry	O
matches	O
it	O
either	O
adds	O
it	O
to	O
the	O
result	O
list	O
(	O
if	O
it	O
is	O
a	O
user	O
entry	O
)	O
or	O
recursively	O
traverses	O
it	O
(	O
if	O
it	O
is	O
a	O
subnode	O
)	O
.	O
</s>
<s>
nearest	B-General_Concept
neighbor	I-General_Concept
searches	O
can	O
be	O
implemented	O
using	O
standard	O
algorithms	O
.	O
</s>
<s>
The	O
PH-tree	B-Data_Structure
can	O
only	O
store	O
integer	O
values	O
.	O
</s>
<s>
Example	O
implementations	O
in	O
Java	B-Language
:	O
</s>
<s>
Example	O
implementations	O
in	O
C++	B-Language
:	O
</s>
<s>
In	O
high	O
dimensions	O
with	O
less	O
than	O
entries	O
,	O
a	O
PH-tree	B-Data_Structure
may	O
have	O
only	O
a	O
single	O
node	O
,	O
effectively	O
“	O
degenerating	O
”	O
into	O
a	O
B-Tree	B-Architecture
with	O
Z-order	B-Algorithm
curve	I-Algorithm
.	O
</s>
<s>
However	O
,	O
this	O
cannot	O
avoid	O
the	O
curse	O
of	O
dimensionality	O
,	O
for	O
high	O
dimensional	O
data	O
with	O
or	O
a	O
PH-tree	B-Data_Structure
is	O
only	O
marginally	O
better	O
than	O
a	O
full	O
scan	O
.	O
</s>
<s>
The	O
PH-tree	B-Data_Structure
is	O
mainly	O
suited	O
for	O
in-memory	O
use	O
.	O
</s>
<s>
This	O
is	O
easier	O
with	O
other	O
spatial	O
indexes	O
,	O
such	O
as	O
R-Trees	B-Library
.	O
</s>
<s>
Java	B-Language
:	O
</s>
<s>
C++	B-Language
:	O
</s>
<s>
C++	B-Language
:	O
</s>
<s>
C++	B-Language
:	O
</s>
