<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
a	O
ternary	B-Data_Structure
tree	I-Data_Structure
is	O
a	O
tree	B-Application
data	I-Application
structure	I-Application
in	O
which	O
each	O
node	O
has	O
at	O
most	O
three	O
child	B-Data_Structure
nodes	I-Data_Structure
,	O
usually	O
distinguished	O
as	O
"	O
left	O
"	O
,	O
“	O
mid	O
”	O
and	O
"	O
right	O
"	O
.	O
</s>
<s>
Nodes	B-Data_Structure
with	O
children	O
are	O
parent	B-Application
nodes	I-Application
,	O
and	O
child	B-Data_Structure
nodes	I-Data_Structure
may	O
contain	O
references	O
to	O
their	O
parents	O
.	O
</s>
<s>
Outside	O
the	O
tree	O
,	O
there	O
is	O
often	O
a	O
reference	O
to	O
the	O
"	O
root	O
"	O
node	O
(	O
the	O
ancestor	O
of	O
all	O
nodes	B-Data_Structure
)	O
,	O
if	O
it	O
exists	O
.	O
</s>
<s>
Any	O
node	O
in	O
the	O
data	O
structure	O
can	O
be	O
reached	O
by	O
starting	O
at	O
root	B-Application
node	I-Application
and	O
repeatedly	O
following	O
references	O
to	O
either	O
the	O
left	O
,	O
mid	O
or	O
right	O
child	O
.	O
</s>
<s>
Ternary	B-Data_Structure
trees	I-Data_Structure
are	O
used	O
to	O
implement	O
Ternary	B-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
and	O
Ternary	B-Application
heaps	I-Application
.	O
</s>
<s>
There	O
is	O
at	O
most	O
one	O
root	B-Application
node	I-Application
in	O
a	O
rooted	O
tree	O
.	O
</s>
<s>
Parent	B-Application
Node	I-Application
-	O
Any	O
node	O
connected	O
by	O
a	O
directed	O
edge	O
to	O
its	O
child	O
or	O
children	O
.	O
</s>
<s>
Child	B-Data_Structure
Node	I-Data_Structure
-	O
Any	O
node	O
connected	O
to	O
a	O
parent	B-Application
node	I-Application
by	O
a	O
directed	O
edge	O
.	O
</s>
<s>
The	O
set	O
of	O
all	O
nodes	B-Data_Structure
at	O
a	O
given	O
depth	O
is	O
sometimes	O
called	O
a	O
level	O
of	O
the	O
tree	O
.	O
</s>
<s>
The	O
root	B-Application
node	I-Application
is	O
at	O
depth	O
zero	O
.	O
</s>
<s>
Sibling	O
-	O
Nodes	B-Data_Structure
that	O
share	O
the	O
same	O
parent	B-Application
node	I-Application
.	O
</s>
<s>
–	O
Let	O
be	O
height	O
of	O
a	O
ternary	B-Data_Structure
tree	I-Data_Structure
.	O
</s>
<s>
–	O
Every	O
tree	O
of	O
height	O
h	O
has	O
at	O
most	O
nodes	B-Data_Structure
.	O
</s>
<s>
Nodes	B-Data_Structure
can	O
be	O
inserted	O
into	O
ternary	B-Data_Structure
trees	I-Data_Structure
in	O
between	O
three	O
other	O
nodes	B-Data_Structure
or	O
added	O
after	O
an	O
external	B-Application
node	I-Application
.	O
</s>
<s>
In	O
Ternary	B-Data_Structure
trees	I-Data_Structure
,	O
a	O
node	O
that	O
is	O
inserted	O
is	O
specified	O
as	O
to	O
which	O
child	O
it	O
is	O
.	O
</s>
<s>
Say	O
that	O
the	O
external	B-Application
node	I-Application
being	O
added	O
onto	O
is	O
node	O
A	O
.	O
</s>
<s>
Insertion	O
on	O
internal	O
nodes	B-Data_Structure
is	O
more	O
complex	O
than	O
on	O
external	B-Application
nodes	I-Application
.	O
</s>
<s>
Only	O
certain	O
nodes	B-Data_Structure
in	O
a	O
ternary	B-Data_Structure
tree	I-Data_Structure
can	O
be	O
removed	O
unambiguously	O
.	O
</s>
<s>
If	O
a	O
node	O
has	O
no	O
children	O
(	O
external	B-Application
node	I-Application
)	O
,	O
deletion	O
is	O
accomplished	O
by	O
setting	O
the	O
child	O
of	O
A	O
's	O
parent	O
to	O
null	O
and	O
A	O
's	O
parent	O
to	O
null	O
.	O
</s>
<s>
The	O
picture	O
below	O
is	O
a	O
binary	B-Language
search	I-Language
tree	I-Language
that	O
represents	O
12	O
two-letter	O
words	O
.	O
</s>
<s>
All	O
nodes	B-Data_Structure
on	O
the	O
left	O
child	O
have	O
smaller	O
values	O
,	O
while	O
all	O
nodes	B-Data_Structure
on	O
the	O
right	O
child	O
have	O
greater	O
values	O
for	O
all	O
nodes	B-Data_Structure
.	O
</s>
<s>
The	O
above	O
picture	O
is	O
a	O
balanced	O
ternary	B-Data_Structure
search	I-Data_Structure
tree	I-Data_Structure
for	O
the	O
same	O
set	O
of	O
12	O
words	O
.	O
</s>
<s>
Two	O
infinite	O
ternary	B-Data_Structure
trees	I-Data_Structure
containing	O
all	O
primitive	O
Pythagorean	O
triples	O
are	O
described	O
in	O
Tree	B-Data_Structure
of	I-Data_Structure
primitive	I-Data_Structure
Pythagorean	I-Data_Structure
triples	I-Data_Structure
and	O
in	O
Formulas	O
for	O
generating	O
Pythagorean	O
triples	O
.	O
</s>
<s>
The	O
root	B-Application
node	I-Application
in	O
both	O
trees	O
contains	O
triple	O
 [ 3 , 4 , 5 ] 	O
.	O
</s>
