<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
an	O
x-fast	B-Data_Structure
trie	I-Data_Structure
is	O
a	O
data	B-General_Concept
structure	I-General_Concept
for	O
storing	O
integers	O
from	O
a	O
bounded	O
domain	O
.	O
</s>
<s>
The	O
structure	O
was	O
proposed	O
by	O
Dan	O
Willard	O
in	O
1982	O
,	O
along	O
with	O
the	O
more	O
complicated	O
y-fast	B-Data_Structure
trie	I-Data_Structure
,	O
as	O
a	O
way	O
to	O
improve	O
the	O
space	O
usage	O
of	O
van	B-Application
Emde	I-Application
Boas	I-Application
trees	I-Application
,	O
while	O
retaining	O
the	O
O(loglogM )	O
query	O
time	O
.	O
</s>
<s>
An	O
x-fast	B-Data_Structure
trie	I-Data_Structure
is	O
a	O
bitwise	O
trie	B-General_Concept
:	O
a	O
binary	O
tree	O
where	O
each	O
subtree	O
stores	O
values	O
whose	O
binary	O
representations	O
start	O
with	O
a	O
common	O
prefix	O
.	O
</s>
<s>
The	O
binary	O
representation	O
of	O
an	O
integer	O
between	O
0	O
and	O
M1	O
uses	O
⌈log2M⌉	O
bits	O
,	O
so	O
the	O
height	O
of	O
the	O
trie	B-General_Concept
is	O
O(logM )	O
.	O
</s>
<s>
All	O
values	O
in	O
the	O
x-fast	B-Data_Structure
trie	I-Data_Structure
are	O
stored	O
at	O
the	O
leaves	O
.	O
</s>
<s>
Each	O
leaf	O
stores	O
a	O
pointer	O
to	O
its	O
predecessor	O
and	O
successor	O
,	O
thereby	O
forming	O
a	O
doubly	B-Data_Structure
linked	I-Data_Structure
list	I-Data_Structure
.	O
</s>
<s>
Finally	O
,	O
there	O
is	O
a	O
hash	B-Algorithm
table	I-Algorithm
for	O
each	O
level	O
that	O
contains	O
all	O
the	O
nodes	O
on	O
that	O
level	O
.	O
</s>
<s>
Together	O
,	O
these	O
hash	B-Algorithm
tables	I-Algorithm
form	O
the	O
level-search	O
structure	O
(	O
LSS	O
)	O
.	O
</s>
<s>
To	O
guarantee	O
the	O
worst-case	O
query	O
times	O
,	O
these	O
hash	B-Algorithm
tables	I-Algorithm
should	O
use	O
dynamic	B-Algorithm
perfect	I-Algorithm
hashing	I-Algorithm
or	O
cuckoo	B-Algorithm
hashing	I-Algorithm
.	O
</s>
<s>
Like	O
van	B-Application
Emde	I-Application
Boas	I-Application
trees	I-Application
,	O
x-fast	B-Data_Structure
tries	I-Data_Structure
support	O
the	O
operations	O
of	O
an	O
ordered	O
associative	B-Application
array	I-Application
.	O
</s>
<s>
This	O
includes	O
the	O
usual	O
associative	B-Application
array	I-Application
operations	O
,	O
along	O
with	O
two	O
more	O
order	O
operations	O
,	O
Successor	O
and	O
Predecessor	O
:	O
</s>
<s>
Finding	O
the	O
value	O
associated	O
with	O
a	O
key	O
k	O
that	O
is	O
in	O
the	O
data	B-General_Concept
structure	I-General_Concept
can	O
be	O
done	O
in	O
constant	O
time	O
by	O
looking	O
up	O
k	O
in	O
LSS[0],	O
which	O
is	O
a	O
hash	B-Algorithm
table	I-Algorithm
on	O
all	O
the	O
leaves	O
.	O
</s>
<s>
To	O
find	O
the	O
successor	O
or	O
predecessor	O
of	O
a	O
key	O
k	O
,	O
we	O
first	O
find	O
Ak	O
,	O
the	O
lowest	O
ancestor	O
of	O
k	O
.	O
This	O
is	O
the	O
node	O
in	O
the	O
trie	B-General_Concept
that	O
has	O
the	O
longest	O
common	O
prefix	O
with	O
k	O
.	O
To	O
find	O
Ak	O
,	O
we	O
perform	O
a	O
binary	O
search	O
on	O
the	O
levels	O
.	O
</s>
<s>
We	O
start	O
at	O
level	O
h/2	O
,	O
where	O
h	O
is	O
the	O
height	O
of	O
the	O
trie	B-General_Concept
.	O
</s>
<s>
On	O
each	O
level	O
,	O
we	O
query	O
the	O
corresponding	O
hash	B-Algorithm
table	I-Algorithm
in	O
the	O
level-search	O
structure	O
with	O
the	O
prefix	O
of	O
k	O
of	O
the	O
right	O
length	O
.	O
</s>
<s>
Once	O
we	O
find	O
the	O
lowest	O
ancestor	O
of	O
k	O
,	O
we	O
know	O
that	O
it	O
has	O
leaves	O
in	O
one	O
of	O
its	O
subtrees	O
(	O
otherwise	O
it	O
would	O
n't	O
be	O
in	O
the	O
trie	B-General_Concept
)	O
and	O
k	O
should	O
be	O
in	O
the	O
other	O
subtree	O
.	O
</s>
<s>
Since	O
the	O
trie	B-General_Concept
has	O
height	O
O(logM )	O
,	O
the	O
binary	O
search	O
for	O
the	O
lowest	O
ancestor	O
takes	O
O(loglogM )	O
time	O
.	O
</s>
<s>
To	O
insert	O
a	O
key-value	O
pair	O
(	O
k	O
,	O
v	O
)	O
,	O
we	O
first	O
find	O
the	O
predecessor	O
and	O
successor	O
of	O
k	O
.	O
Then	O
we	O
create	O
a	O
new	O
leaf	O
for	O
k	O
,	O
insert	O
it	O
in	O
the	O
linked	O
list	O
of	O
leaves	O
between	O
the	O
successor	O
and	O
predecessor	O
,	O
and	O
give	O
it	O
a	O
pointer	O
to	O
v	O
.	O
Next	O
,	O
we	O
walk	O
from	O
the	O
root	O
to	O
the	O
new	O
leaf	O
,	O
creating	O
the	O
necessary	O
nodes	O
on	O
the	O
way	O
down	O
,	O
inserting	O
them	O
into	O
the	O
respective	O
hash	B-Algorithm
tables	I-Algorithm
and	O
updating	O
descendant	O
pointers	O
where	O
necessary	O
.	O
</s>
<s>
Since	O
we	O
have	O
to	O
walk	O
down	O
the	O
entire	O
height	O
of	O
the	O
trie	B-General_Concept
,	O
this	O
process	O
takes	O
O(logM )	O
time	O
.	O
</s>
<s>
To	O
delete	O
a	O
key	O
k	O
,	O
we	O
find	O
its	O
leaf	O
using	O
the	O
hash	B-Algorithm
table	I-Algorithm
on	O
the	O
leaves	O
.	O
</s>
<s>
Then	O
we	O
walk	O
from	O
the	O
leaf	O
to	O
the	O
root	O
of	O
the	O
trie	B-General_Concept
,	O
removing	O
all	O
nodes	O
whose	O
subtree	O
only	O
contained	O
k	O
and	O
updating	O
the	O
descendant	O
pointers	O
where	O
necessary	O
.	O
</s>
<s>
Like	O
insertion	O
,	O
this	O
takes	O
O(logM )	O
time	O
,	O
as	O
we	O
have	O
to	O
walk	O
through	O
every	O
level	O
of	O
the	O
trie	B-General_Concept
.	O
</s>
<s>
Willard	O
introduced	O
x-fast	B-Data_Structure
tries	I-Data_Structure
largely	O
as	O
an	O
introduction	O
to	O
y-fast	B-Data_Structure
tries	I-Data_Structure
,	O
which	O
provide	O
the	O
same	O
query	O
time	O
,	O
while	O
using	O
only	O
O(n )	O
space	O
and	O
allowing	O
insertions	O
and	O
deletions	O
in	O
O(loglogM )	O
time	O
.	O
</s>
<s>
A	O
compression	O
technique	O
similar	O
to	O
patricia	O
tries	B-General_Concept
can	O
be	O
used	O
to	O
significantly	O
reduce	O
the	O
space	O
usage	O
of	O
x-fast	B-Data_Structure
tries	I-Data_Structure
in	O
practice	O
.	O
</s>
<s>
By	O
using	O
an	O
exponential	O
search	O
before	O
the	O
binary	O
search	O
over	O
the	O
levels	O
and	O
by	O
querying	O
not	O
only	O
the	O
current	O
prefix	O
x	O
,	O
but	O
also	O
its	O
successor	O
x+1	O
,	O
x-fast	B-Data_Structure
tries	I-Data_Structure
can	O
answer	O
predecessor	O
and	O
successor	O
queries	O
in	O
time	O
O(loglogΔ )	O
,	O
where	O
Δ	O
is	O
the	O
difference	O
between	O
the	O
query	O
value	O
and	O
its	O
predecessor	O
or	O
successor	O
.	O
</s>
