<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
a	O
ternary	B-Data_Structure
search	I-Data_Structure
tree	I-Data_Structure
is	O
a	O
type	O
of	O
trie	B-General_Concept
(	O
sometimes	O
called	O
a	O
prefix	B-General_Concept
tree	I-General_Concept
)	O
where	O
nodes	O
are	O
arranged	O
in	O
a	O
manner	O
similar	O
to	O
a	O
binary	B-Language
search	I-Language
tree	I-Language
,	O
but	O
with	O
up	O
to	O
three	O
children	O
rather	O
than	O
the	O
binary	O
tree	O
's	O
limit	O
of	O
two	O
.	O
</s>
<s>
Like	O
other	O
prefix	B-General_Concept
trees	I-General_Concept
,	O
a	O
ternary	B-Data_Structure
search	I-Data_Structure
tree	I-Data_Structure
can	O
be	O
used	O
as	O
an	O
associative	B-Application
map	I-Application
structure	O
with	O
the	O
ability	O
for	O
incremental	O
string	B-Algorithm
search	I-Algorithm
.	O
</s>
<s>
However	O
,	O
ternary	B-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
are	O
more	O
space	O
efficient	O
compared	O
to	O
standard	O
prefix	B-General_Concept
trees	I-General_Concept
,	O
at	O
the	O
cost	O
of	O
speed	O
.	O
</s>
<s>
Common	O
applications	O
for	O
ternary	B-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
include	O
spell-checking	B-Application
and	O
auto-completion	O
.	O
</s>
<s>
Each	O
node	O
of	O
a	O
ternary	B-Data_Structure
search	I-Data_Structure
tree	I-Data_Structure
stores	O
a	O
single	O
character	O
,	O
an	O
object	O
(	O
or	O
a	O
pointer	O
to	O
an	O
object	O
depending	O
on	O
implementation	O
)	O
,	O
and	O
pointers	O
to	O
its	O
three	O
children	O
conventionally	O
named	O
equal	O
kid	O
,	O
lo	O
kid	O
and	O
hi	O
kid	O
,	O
which	O
can	O
also	O
be	O
referred	O
respectively	O
as	O
middle	O
(	O
child	O
)	O
,	O
lower	O
(	O
child	O
)	O
and	O
higher	O
(	O
child	O
)	O
.	O
</s>
<s>
The	O
figure	O
below	O
shows	O
a	O
ternary	B-Data_Structure
search	I-Data_Structure
tree	I-Data_Structure
with	O
the	O
strings	O
"	O
cute	O
"	O
,	O
"	O
cup	O
"	O
,	O
"	O
at	O
"	O
,	O
"	O
as	O
"	O
,	O
"	O
he	O
"	O
,	O
"	O
us	O
"	O
and	O
"	O
i	O
"	O
:	O
</s>
<s>
As	O
with	O
other	O
trie	B-General_Concept
data	B-General_Concept
structures	I-General_Concept
,	O
each	O
node	O
in	O
a	O
ternary	B-Data_Structure
search	I-Data_Structure
tree	I-Data_Structure
represents	O
a	O
prefix	O
of	O
the	O
stored	O
strings	O
.	O
</s>
<s>
Like	O
binary	B-Language
search	I-Language
trees	I-Language
and	O
other	O
data	B-General_Concept
structures	I-General_Concept
,	O
ternary	B-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
can	O
become	O
degenerate	O
depending	O
on	O
the	O
order	O
of	O
the	O
keys	O
.	O
</s>
<s>
The	O
running	O
time	O
of	O
ternary	B-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
varies	O
significantly	O
with	O
the	O
input	O
.	O
</s>
<s>
Ternary	B-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
run	O
best	O
when	O
given	O
several	O
similar	O
strings	O
,	O
especially	O
when	O
those	O
strings	O
share	O
a	O
common	O
prefix	O
.	O
</s>
<s>
Alternatively	O
,	O
ternary	B-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
are	O
effective	O
when	O
storing	O
a	O
large	O
number	O
of	O
relatively	O
short	O
strings	O
(	O
such	O
as	O
words	O
in	O
a	O
dictionary	B-Operating_System
)	O
.	O
</s>
<s>
Running	O
times	O
for	O
ternary	B-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
are	O
similar	O
to	O
binary	B-Language
search	I-Language
trees	I-Language
,	O
in	O
that	O
they	O
typically	O
run	O
in	O
logarithmic	O
time	O
,	O
but	O
can	O
run	O
in	O
linear	O
time	O
in	O
the	O
degenerate	O
(	O
worst	O
)	O
case	O
.	O
</s>
<s>
Thus	O
,	O
in	O
a	O
ternary	B-Data_Structure
search	I-Data_Structure
tree	I-Data_Structure
on	O
a	O
small	O
number	O
of	O
very	O
large	O
strings	O
the	O
lengths	O
of	O
the	O
strings	O
can	O
dominate	O
the	O
runtime	O
.	O
</s>
<s>
Time	O
complexities	O
for	O
ternary	B-Data_Structure
search	I-Data_Structure
tree	I-Data_Structure
operations	O
:	O
</s>
<s>
While	O
being	O
slower	O
than	O
other	O
prefix	B-General_Concept
trees	I-General_Concept
,	O
ternary	B-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
can	O
be	O
better	O
suited	O
for	O
larger	O
data	O
sets	O
due	O
to	O
their	O
space-efficiency	O
.	O
</s>
<s>
Hashtables	B-Algorithm
can	O
also	O
be	O
used	O
in	O
place	O
of	O
ternary	B-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
for	O
mapping	B-General_Concept
strings	O
to	O
values	O
.	O
</s>
<s>
However	O
,	O
hash	B-Algorithm
maps	I-Algorithm
also	O
frequently	O
use	O
more	O
memory	O
than	O
ternary	B-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
(	O
but	O
not	O
as	O
much	O
as	O
tries	B-General_Concept
)	O
.	O
</s>
<s>
Additionally	O
,	O
hash	B-Algorithm
maps	I-Algorithm
are	O
typically	O
slower	O
at	O
reporting	O
a	O
string	O
that	O
is	O
not	O
in	O
the	O
same	O
data	B-General_Concept
structure	I-General_Concept
,	O
because	O
it	O
must	O
compare	O
the	O
entire	O
string	O
rather	O
than	O
just	O
the	O
first	O
few	O
characters	O
.	O
</s>
<s>
There	O
is	O
some	O
evidence	O
that	O
shows	O
ternary	B-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
running	O
faster	O
than	O
hash	B-Algorithm
maps	I-Algorithm
.	O
</s>
<s>
Additionally	O
,	O
hash	B-Algorithm
maps	I-Algorithm
do	O
not	O
allow	O
for	O
many	O
of	O
the	O
uses	O
of	O
ternary	B-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
,	O
such	O
as	O
near-neighbor	O
lookups	O
.	O
</s>
<s>
If	O
storing	O
dictionary	B-Operating_System
words	O
is	O
all	O
that	O
is	O
required	O
(	O
i.e.	O
,	O
storage	O
of	O
information	O
auxiliary	O
to	O
each	O
word	O
is	O
not	O
required	O
)	O
,	O
a	O
minimal	O
deterministic	B-General_Concept
acyclic	I-General_Concept
finite	I-General_Concept
state	I-General_Concept
automaton	I-General_Concept
(	O
DAFSA	B-General_Concept
)	O
would	O
use	O
less	O
space	O
than	O
a	O
trie	B-General_Concept
or	O
a	O
ternary	B-Data_Structure
search	I-Data_Structure
tree	I-Data_Structure
.	O
</s>
<s>
This	O
is	O
because	O
a	O
DAFSA	B-General_Concept
can	O
compress	O
identical	O
branches	O
from	O
the	O
trie	B-General_Concept
which	O
correspond	O
to	O
the	O
same	O
suffixes	O
(	O
or	O
parts	O
)	O
of	O
different	O
words	O
being	O
stored	O
.	O
</s>
<s>
Ternary	B-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
can	O
be	O
used	O
to	O
solve	O
many	O
problems	O
in	O
which	O
a	O
large	O
number	O
of	O
strings	O
must	O
be	O
stored	O
and	O
retrieved	O
in	O
an	O
arbitrary	O
order	O
.	O
</s>
<s>
Anytime	O
a	O
trie	B-General_Concept
could	O
be	O
used	O
but	O
a	O
less	O
memory-consuming	O
structure	O
is	O
preferred	O
.	O
</s>
<s>
A	O
quick	O
and	O
space-saving	O
data	B-General_Concept
structure	I-General_Concept
for	O
mapping	B-General_Concept
strings	O
to	O
other	O
data	O
.	O
</s>
<s>
As	O
a	O
spell	B-Application
check	I-Application
.	O
</s>
<s>
Near-neighbor	B-Algorithm
searching	I-Algorithm
(	O
of	O
which	O
spell-checking	B-Application
is	O
a	O
special	O
case	O
)	O
.	O
</s>
<s>
In	O
place	O
of	O
a	O
hash	B-Algorithm
table	I-Algorithm
.	O
</s>
