<s>
A	O
bitwise	O
trie	B-General_Concept
is	O
a	O
special	O
form	O
of	O
trie	B-General_Concept
where	O
each	O
node	O
with	O
its	O
child-branches	O
represents	O
a	O
bit	O
sequence	O
of	O
one	O
or	O
more	O
bits	O
of	O
a	O
key	O
.	O
</s>
<s>
A	O
bitwise	B-Data_Structure
trie	I-Data_Structure
with	I-Data_Structure
bitmap	I-Data_Structure
uses	O
a	O
bitmap	B-Data_Structure
to	O
denote	O
valid	O
child	O
branches	O
.	O
</s>
<s>
A	O
trie	B-General_Concept
is	O
a	O
type	O
of	O
search	B-Data_Structure
tree	I-Data_Structure
where	O
–	O
unlike	O
for	O
example	O
a	O
B-tree	B-Architecture
–	O
keys	O
are	O
not	O
stored	O
in	O
the	O
nodes	O
but	O
in	O
the	O
path	O
to	O
leafs	O
.	O
</s>
<s>
In	O
a	O
"	O
classic	O
"	O
trie	B-General_Concept
,	O
each	O
node	O
with	O
its	O
child-branches	O
represents	O
one	O
symbol	O
of	O
the	O
alphabet	O
of	O
one	O
position	O
(	O
character	O
)	O
of	O
a	O
key	O
.	O
</s>
<s>
In	O
bitwise	O
tries	B-General_Concept
,	O
keys	O
are	O
treated	O
as	O
bit-sequence	O
of	O
some	O
binary	O
representation	O
and	O
each	O
node	O
with	O
its	O
child-branches	O
represents	O
the	O
value	O
of	O
a	O
sub-sequence	O
of	O
this	O
bit-sequence	O
to	O
form	O
a	O
binary	O
tree	O
(	O
the	O
sub-sequence	O
contains	O
only	O
one	O
bit	O
)	O
or	O
n-ary	O
tree	O
(	O
the	O
sub-sequence	O
contains	O
multiple	O
bits	O
)	O
.	O
</s>
<s>
To	O
give	O
an	O
example	O
that	O
explains	O
the	O
difference	O
between	O
"	O
classic	O
"	O
tries	B-General_Concept
and	O
bitwise	O
tries	B-General_Concept
:	O
For	O
numbers	O
as	O
keys	O
,	O
the	O
alphabet	O
for	O
a	O
trie	B-General_Concept
could	O
consist	O
of	O
the	O
symbols	O
'	O
0	O
 '	O
..	O
'	O
9	O
 '	O
to	O
represent	O
digits	O
of	O
a	O
number	O
in	O
the	O
decimal	O
system	O
and	O
the	O
nodes	O
would	O
have	O
up	O
to	O
10	O
possible	O
children	O
.	O
</s>
<s>
There	O
are	O
multiple	O
straight	O
forward	O
approaches	O
to	O
implement	O
such	O
a	O
trie	B-General_Concept
as	O
physical	O
data	O
structure	O
.	O
</s>
<s>
An	O
ideal	O
trie	B-General_Concept
has	O
an	O
access	O
time	O
that	O
is	O
independent	O
of	O
the	O
amount	O
of	O
keys	O
stored	O
.	O
</s>
<s>
presented	O
a	O
time	O
and	O
space	O
efficient	O
solution	O
for	O
tries	B-General_Concept
named	O
Array	O
Mapped	O
Tree	O
(	O
AMT	O
)	O
.	O
</s>
<s>
The	O
Hash	B-Data_Structure
array	I-Data_Structure
mapped	I-Data_Structure
trie	I-Data_Structure
(	O
HAMT	O
)	O
is	O
based	O
on	O
AMT	O
.	O
</s>
<s>
The	O
compact	O
trie	B-General_Concept
node	O
representation	O
uses	O
a	O
bitmap	B-Data_Structure
to	O
mark	O
every	O
valid	O
branch	O
–	O
a	O
bitwise	B-Data_Structure
trie	I-Data_Structure
with	I-Data_Structure
bitmap	I-Data_Structure
.	O
</s>
<s>
The	O
AMT	O
uses	O
eight	O
32-bit	O
bitmaps	O
per	O
node	O
to	O
represent	O
a	O
256-ary	O
trie	B-General_Concept
that	O
is	O
able	O
to	O
represent	O
an	O
8	O
bit	O
sequence	O
per	O
node	O
.	O
</s>
<s>
With	O
64-Bit-CPUs	O
(	O
64-bit	B-Device
computing	I-Device
)	O
a	O
variation	O
is	O
to	O
have	O
a	O
64-ary	O
trie	B-General_Concept
with	O
only	O
one	O
64-bit	B-Device
bitmap	B-Data_Structure
per	O
node	O
that	O
is	O
able	O
to	O
represent	O
a	O
6	O
bit	O
sequence	O
.	O
</s>
<s>
To	O
determine	O
the	O
index	B-Data_Structure
of	O
the	O
child	O
pointer	O
of	O
a	O
node	O
for	O
such	O
a	O
given	O
6-bit	O
value	O
,	O
the	O
amount	O
of	O
preceding	O
child	O
pointers	O
has	O
to	O
be	O
calculated	O
.	O
</s>
<s>
The	O
offset	O
to	O
find	O
the	O
index	B-Data_Structure
based	O
on	O
the	O
current	O
node	O
index	B-Data_Structure
is	O
the	O
amount	O
of	O
least	O
significant	O
bits	O
set	O
in	O
the	O
bitmap	B-Data_Structure
before	O
the	O
target	O
position	O
plus	O
one	O
for	O
the	O
bitmap	B-Data_Structure
.	O
</s>
<s>
and	O
many	O
modern	O
CPUs	O
even	O
provide	O
CTPOP	O
as	O
a	O
dedicated	O
instruction	O
treated	O
by	O
compilers	O
as	O
intrinsic	B-Application
function	I-Application
.	O
</s>
<s>
How	O
to	O
use	O
this	O
principle	O
for	O
an	O
universal	O
index	B-Data_Structure
for	O
database	O
and	O
Information	B-Library
retrieval	I-Library
applications	O
is	O
described	O
in	O
.	O
</s>
<s>
In	O
this	O
example	O
implementation	O
for	O
a	O
bitwise	B-Data_Structure
trie	I-Data_Structure
with	I-Data_Structure
bitmap	I-Data_Structure
,	O
nodes	O
are	O
placed	O
in	O
an	O
array	O
of	O
long	O
(	O
64-bit	B-Device
)	O
integers	O
.	O
</s>
<s>
A	O
node	O
is	O
identified	O
by	O
the	O
position	O
(	O
index	B-Data_Structure
)	O
in	O
that	O
array	O
.	O
</s>
<s>
The	O
index	B-Data_Structure
of	O
the	O
root	O
node	O
marks	O
the	O
root	O
of	O
the	O
trie	B-General_Concept
.	O
</s>
<s>
In	O
addition	O
,	O
nodes	O
,	O
that	O
are	O
replaced	O
,	O
are	O
collected	O
in	O
free	B-General_Concept
lists	I-General_Concept
and	O
their	O
space	O
is	O
recycled	O
.	O
</s>
<s>
Without	O
this	O
recycling	O
,	O
the	O
data	O
structure	O
can	O
be	O
used	O
to	O
implement	O
a	O
persistent	B-Application
data	I-Application
structure	I-Application
by	O
just	O
keeping	O
the	O
previous	O
root	O
index	B-Data_Structure
and	O
never	O
overriding	O
existing	O
nodes	O
but	O
always	O
creating	O
a	O
copy	O
of	O
a	O
changed	O
node	O
.	O
</s>
<s>
Leaf	O
nodes	O
are	O
inlined	O
:	O
Instead	O
of	O
having	O
a	O
child-pointer	O
to	O
a	O
leaf	O
node	O
,	O
the	O
bitmap	B-Data_Structure
of	O
the	O
leaf	O
node	O
itself	O
is	O
stored	O
.	O
</s>
<s>
Instances	O
of	O
this	O
interface	O
are	O
created	O
on	O
demand	O
during	O
a	O
trie	B-General_Concept
traversal	O
.	O
</s>
<s>
Nonrelevant	O
child	O
nodes	O
do	O
n't	O
have	O
to	O
be	O
accessed	O
because	O
the	O
bitmap	B-Data_Structure
and	O
a	O
bitwise	O
AND	O
operation	O
allows	O
to	O
determine	O
the	O
result	O
upfront	O
.	O
</s>
<s>
Using	O
the	O
virtual	O
node	O
approach	O
,	O
range	O
queries	B-Library
can	O
be	O
accomplished	O
by	O
intersecting	O
a	O
range	O
generating	O
virtual	O
trie	B-General_Concept
(	O
see	O
below	O
)	O
with	O
another	O
operator	O
.	O
</s>
