<s>
An	O
anatree	B-Data_Structure
is	O
a	O
data	B-General_Concept
structure	I-General_Concept
designed	O
to	O
solve	O
anagrams	O
.	O
</s>
<s>
These	O
problems	O
are	O
commonly	O
encountered	O
in	O
word	O
games	O
like	O
Scrabble	B-Application
or	O
in	O
newspaper	O
crossword	O
puzzles	O
.	O
</s>
<s>
These	O
problems	O
are	O
classified	O
as	O
Constraint	B-Application
satisfaction	I-Application
problem	I-Application
in	O
computer	O
science	O
literature	O
.	O
</s>
<s>
An	O
anatree	B-Data_Structure
is	O
represented	O
as	O
a	O
directed	O
tree	O
which	O
contains	O
a	O
set	O
of	O
words	O
(	O
W	O
)	O
encoded	O
as	O
strings	O
in	O
some	O
alphabet	B-Application
.	O
</s>
<s>
The	O
internal	O
vertices	O
are	O
labelled	O
with	O
some	O
letter	O
in	O
the	O
alphabet	B-Application
and	O
the	O
leaves	O
contain	O
words	O
.	O
</s>
<s>
An	O
anatree	B-Data_Structure
has	O
the	O
property	O
that	O
the	O
sum	O
of	O
the	O
edge	O
labels	O
from	O
the	O
root	O
to	O
the	O
leaf	O
is	O
the	O
length	O
of	O
the	O
word	O
stored	O
at	O
the	O
leaf	O
.	O
</s>
<s>
Anatrees	B-Data_Structure
are	O
intended	O
to	O
be	O
read	O
only	O
data	B-General_Concept
structures	I-General_Concept
with	O
all	O
the	O
words	O
available	O
at	O
construction	O
time	O
.	O
</s>
<s>
A	O
mixed	O
anatree	B-Data_Structure
is	O
an	O
anatree	B-Data_Structure
where	O
the	O
internal	O
vertices	O
also	O
store	O
words	O
.	O
</s>
<s>
A	O
mixed	O
anatree	B-Data_Structure
can	O
have	O
words	O
of	O
varying	O
lengths	O
,	O
where	O
as	O
in	O
a	O
regular	O
anatree	B-Data_Structure
,	O
all	O
words	O
are	O
of	O
the	O
same	O
length	O
.	O
</s>
<s>
A	O
number	O
of	O
data	B-General_Concept
structures	I-General_Concept
have	O
been	O
proposed	O
to	O
solve	O
anagrams	O
in	O
constant	O
time	O
.	O
</s>
<s>
Two	O
of	O
the	O
most	O
commonly	O
used	O
data	B-General_Concept
structures	I-General_Concept
are	O
the	O
alphabetic	O
map	O
and	O
the	O
frequency	O
map	O
.	O
</s>
<s>
The	O
alphabetic	O
map	O
maintains	O
a	O
hash	B-Algorithm
table	I-Algorithm
of	O
all	O
the	O
possible	O
words	O
that	O
can	O
be	O
in	O
the	O
language	O
(	O
this	O
is	O
referred	O
to	O
as	O
the	O
lexicon	B-Application
)	O
.	O
</s>
<s>
This	O
sorted	O
string	O
maps	O
onto	O
a	O
word	O
in	O
the	O
hash	B-Algorithm
table	I-Algorithm
.	O
</s>
<s>
Hence	O
finding	O
the	O
anagram	O
requires	O
sorting	O
the	O
letters	O
and	O
looking	O
up	O
the	O
word	O
in	O
the	O
hash	B-Algorithm
table	I-Algorithm
.	O
</s>
<s>
The	O
sorting	O
can	O
be	O
done	O
in	O
linear	O
time	O
with	O
counting	B-Algorithm
sort	I-Algorithm
and	O
hash	B-Algorithm
table	I-Algorithm
look	O
ups	O
can	O
be	O
done	O
in	O
constant	O
time	O
.	O
</s>
<s>
For	O
example	O
,	O
given	O
the	O
word	O
ANATREE	B-Data_Structure
,	O
the	O
alphabetic	O
map	O
would	O
produce	O
a	O
mapping	O
of	O
.	O
</s>
<s>
A	O
frequency	O
map	O
also	O
stores	O
the	O
list	O
of	O
all	O
possible	O
words	O
in	O
the	O
lexicon	B-Application
in	O
a	O
hash	B-Algorithm
table	I-Algorithm
.	O
</s>
<s>
For	O
a	O
given	O
input	O
string	O
,	O
the	O
frequency	O
map	O
maintains	O
the	O
frequencies	O
(	O
number	O
of	O
appearances	O
)	O
of	O
all	O
the	O
letters	O
and	O
uses	O
this	O
count	O
to	O
perform	O
a	O
look	O
up	O
in	O
the	O
hash	B-Algorithm
table	I-Algorithm
.	O
</s>
<s>
The	O
worst	O
case	O
execution	O
time	O
is	O
found	O
to	O
be	O
linear	O
in	O
size	O
of	O
the	O
lexicon	B-Application
.	O
</s>
<s>
For	O
example	O
,	O
given	O
the	O
word	O
ANATREE	B-Data_Structure
,	O
the	O
alphabetic	O
map	O
would	O
produce	O
a	O
mapping	O
of	O
.	O
</s>
<s>
The	O
construction	O
of	O
an	O
anatree	B-Data_Structure
begins	O
by	O
selecting	O
a	O
label	O
for	O
the	O
root	O
and	O
partitioning	O
words	O
based	O
on	O
the	O
label	O
chosen	O
for	O
the	O
root	O
.	O
</s>
<s>
Anatree	B-Data_Structure
construction	O
is	O
non-canonical	O
for	O
a	O
given	O
set	O
of	O
words	O
,	O
depending	O
on	O
the	O
label	O
chosen	O
for	O
the	O
root	O
,	O
the	O
anatree	B-Data_Structure
will	O
differ	O
accordingly	O
.	O
</s>
<s>
The	O
performance	O
of	O
the	O
anatree	B-Data_Structure
is	O
greatly	O
impacted	O
by	O
the	O
choice	O
of	O
labels	O
.	O
</s>
<s>
This	O
approach	O
prevents	O
long	O
sequences	O
of	O
zero	O
labeled	O
edges	O
since	O
they	O
do	O
not	O
contribute	O
letters	O
to	O
the	O
words	O
generated	O
by	O
the	O
anatree	B-Data_Structure
.	O
</s>
<s>
To	O
find	O
a	O
word	O
in	O
an	O
anatree	B-Data_Structure
,	O
start	O
at	O
the	O
root	O
,	O
depending	O
on	O
the	O
frequency	O
of	O
the	O
label	O
in	O
the	O
given	O
input	O
string	O
,	O
follow	O
the	O
edge	O
that	O
has	O
that	O
frequency	O
till	O
the	O
leaf	O
.	O
</s>
<s>
For	O
example	O
,	O
consider	O
the	O
anatree	B-Data_Structure
in	O
the	O
figure	O
,	O
to	O
find	O
the	O
word	O
,	O
the	O
given	O
string	O
may	O
be	O
.	O
</s>
<s>
A	O
lexicon	B-Application
that	O
stores	O
words	O
(	O
each	O
word	O
can	O
be	O
characters	O
long	O
)	O
in	O
an	O
alphabet	B-Application
has	O
the	O
following	O
space	O
requirements	O
.	O
</s>
