<s>
A	O
prefix	B-Algorithm
code	I-Algorithm
is	O
a	O
type	O
of	O
code	O
system	O
distinguished	O
by	O
its	O
possession	O
of	O
the	O
"	O
prefix	O
property	O
"	O
,	O
which	O
requires	O
that	O
there	O
is	O
no	O
whole	O
code	O
word	O
in	O
the	O
system	O
that	O
is	O
a	O
prefix	O
(	O
initial	O
segment	O
)	O
of	O
any	O
other	O
code	O
word	O
in	O
the	O
system	O
.	O
</s>
<s>
It	O
is	O
trivially	O
true	O
for	O
fixed-length	O
code	O
,	O
so	O
only	O
a	O
point	O
of	O
consideration	O
in	O
variable-length	B-Algorithm
code	I-Algorithm
.	O
</s>
<s>
A	O
prefix	B-Algorithm
code	I-Algorithm
is	O
a	O
uniquely	O
decodable	O
code	O
:	O
given	O
a	O
complete	O
and	O
accurate	O
sequence	O
,	O
a	O
receiver	O
can	O
identify	O
each	O
word	O
without	O
requiring	O
a	O
special	O
marker	O
between	O
words	O
.	O
</s>
<s>
However	O
,	O
there	O
are	O
uniquely	O
decodable	O
codes	O
that	O
are	O
not	O
prefix	B-Algorithm
codes	I-Algorithm
;	O
for	O
instance	O
,	O
the	O
reverse	O
of	O
a	O
prefix	B-Algorithm
code	I-Algorithm
is	O
still	O
uniquely	O
decodable	O
(	O
it	O
is	O
a	O
suffix	O
code	O
)	O
,	O
but	O
it	O
is	O
not	O
necessarily	O
a	O
prefix	B-Algorithm
code	I-Algorithm
.	O
</s>
<s>
Prefix	B-Algorithm
codes	I-Algorithm
are	O
also	O
known	O
as	O
prefix-free	B-Algorithm
codes	I-Algorithm
,	O
prefix	O
condition	O
codes	O
and	O
instantaneous	B-Algorithm
codes	I-Algorithm
.	O
</s>
<s>
Although	O
Huffman	B-General_Concept
coding	I-General_Concept
is	O
just	O
one	O
of	O
many	O
algorithms	O
for	O
deriving	O
prefix	B-Algorithm
codes	I-Algorithm
,	O
prefix	B-Algorithm
codes	I-Algorithm
are	O
also	O
widely	O
referred	O
to	O
as	O
"	O
Huffman	B-General_Concept
codes	I-General_Concept
"	O
,	O
even	O
when	O
the	O
code	O
was	O
not	O
produced	O
by	O
a	O
Huffman	B-General_Concept
algorithm	I-General_Concept
.	O
</s>
<s>
The	O
term	O
comma-free	O
code	O
is	O
sometimes	O
also	O
applied	O
as	O
a	O
synonym	O
for	O
prefix-free	B-Algorithm
codes	I-Algorithm
but	O
in	O
most	O
mathematical	O
books	O
and	O
articles	O
(	O
e.g.	O
)	O
</s>
<s>
a	O
comma-free	O
code	O
is	O
used	O
to	O
mean	O
a	O
self-synchronizing	O
code	O
,	O
a	O
subclass	O
of	O
prefix	B-Algorithm
codes	I-Algorithm
.	O
</s>
<s>
Using	O
prefix	B-Algorithm
codes	I-Algorithm
,	O
a	O
message	O
can	O
be	O
transmitted	O
as	O
a	O
sequence	O
of	O
concatenated	O
code	O
words	O
,	O
without	O
any	O
out-of-band	B-Protocol
markers	O
or	O
(	O
alternatively	O
)	O
special	O
markers	O
between	O
words	O
to	O
frame	O
the	O
words	O
in	O
the	O
message	O
.	O
</s>
<s>
The	O
variable-length	O
Huffman	B-General_Concept
codes	I-General_Concept
,	O
country	O
calling	O
codes	O
,	O
the	O
country	O
and	O
publisher	O
parts	O
of	O
ISBNs	B-Library
,	O
the	O
Secondary	O
Synchronization	O
Codes	O
used	O
in	O
the	O
UMTS	B-Protocol
W-CDMA	O
3G	O
Wireless	O
Standard	O
,	O
and	O
the	O
instruction	B-General_Concept
sets	I-General_Concept
(	O
machine	O
language	O
)	O
of	O
most	O
computer	O
microarchitectures	O
are	O
prefix	B-Algorithm
codes	I-Algorithm
.	O
</s>
<s>
Prefix	B-Algorithm
codes	I-Algorithm
are	O
not	O
error-correcting	B-Error_Name
codes	I-Error_Name
.	O
</s>
<s>
In	O
practice	O
,	O
a	O
message	O
might	O
first	O
be	O
compressed	O
with	O
a	O
prefix	B-Algorithm
code	I-Algorithm
,	O
and	O
then	O
encoded	O
again	O
with	O
channel	O
coding	O
(	O
including	O
error	O
correction	O
)	O
before	O
transmission	O
.	O
</s>
<s>
For	O
any	O
uniquely	O
decodable	O
code	O
there	O
is	O
a	O
prefix	B-Algorithm
code	I-Algorithm
that	O
has	O
the	O
same	O
code	O
word	O
lengths	O
.	O
</s>
<s>
If	O
every	O
word	O
in	O
the	O
code	O
has	O
the	O
same	O
length	O
,	O
the	O
code	O
is	O
called	O
a	O
fixed-length	O
code	O
,	O
or	O
a	O
block	O
code	O
(	O
though	O
the	O
term	O
block	O
code	O
is	O
also	O
used	O
for	O
fixed-size	O
error-correcting	B-Error_Name
codes	I-Error_Name
in	O
channel	O
coding	O
)	O
.	O
</s>
<s>
A	O
fixed-length	O
code	O
is	O
necessarily	O
a	O
prefix	B-Algorithm
code	I-Algorithm
.	O
</s>
<s>
Truncated	B-Algorithm
binary	I-Algorithm
encoding	I-Algorithm
is	O
a	O
straightforward	O
generalization	O
of	O
fixed-length	O
codes	O
to	O
deal	O
with	O
cases	O
where	O
the	O
number	O
of	O
symbols	O
n	O
is	O
not	O
a	O
power	O
of	O
two	O
.	O
</s>
<s>
Huffman	B-General_Concept
coding	I-General_Concept
is	O
a	O
more	O
sophisticated	O
technique	O
for	O
constructing	O
variable-length	O
prefix	B-Algorithm
codes	I-Algorithm
.	O
</s>
<s>
The	O
Huffman	B-General_Concept
coding	I-General_Concept
algorithm	O
takes	O
as	O
input	O
the	O
frequencies	O
that	O
the	O
code	O
words	O
should	O
have	O
,	O
and	O
constructs	O
a	O
prefix	B-Algorithm
code	I-Algorithm
that	O
minimizes	O
the	O
weighted	O
average	O
of	O
the	O
code	O
word	O
lengths	O
.	O
</s>
<s>
This	O
is	O
a	O
form	O
of	O
lossless	B-Algorithm
data	I-Algorithm
compression	I-Algorithm
based	O
on	O
entropy	B-Algorithm
encoding	I-Algorithm
.	O
</s>
<s>
Some	O
codes	O
mark	O
the	O
end	O
of	O
a	O
code	O
word	O
with	O
a	O
special	O
"	O
comma	O
"	O
symbol	O
(	O
also	O
called	O
a	O
Sentinel	B-Data_Structure
value	I-Data_Structure
)	O
,	O
different	O
from	O
normal	O
data	O
.	O
</s>
<s>
Morse	O
code	O
is	O
an	O
everyday	O
example	O
of	O
a	O
variable-length	B-Algorithm
code	I-Algorithm
with	O
a	O
comma	O
.	O
</s>
<s>
Similarly	O
,	O
Fibonacci	B-Algorithm
coding	I-Algorithm
uses	O
a	O
"	O
11	O
"	O
to	O
mark	O
the	O
end	O
of	O
every	O
code	O
word	O
.	O
</s>
<s>
Self-synchronizing	O
codes	O
are	O
prefix	B-Algorithm
codes	I-Algorithm
that	O
allow	O
frame	O
synchronization	O
.	O
</s>
<s>
A	O
suffix	O
code	O
is	O
a	O
set	O
of	O
words	O
none	O
of	O
which	O
is	O
a	O
suffix	O
of	O
any	O
other	O
;	O
equivalently	O
,	O
a	O
set	O
of	O
words	O
which	O
are	O
the	O
reverse	O
of	O
a	O
prefix	B-Algorithm
code	I-Algorithm
.	O
</s>
<s>
As	O
with	O
a	O
prefix	B-Algorithm
code	I-Algorithm
,	O
the	O
representation	O
of	O
a	O
string	O
as	O
a	O
concatenation	O
of	O
such	O
words	O
is	O
unique	O
.	O
</s>
<s>
An	O
optimal	O
prefix	B-Algorithm
code	I-Algorithm
is	O
a	O
prefix	B-Algorithm
code	I-Algorithm
with	O
minimal	O
average	O
length	O
.	O
</s>
<s>
That	O
is	O
,	O
assume	O
an	O
alphabet	O
of	O
symbols	O
with	O
probabilities	O
for	O
a	O
prefix	B-Algorithm
code	I-Algorithm
.	O
</s>
<s>
If	O
is	O
another	O
prefix	B-Algorithm
code	I-Algorithm
and	O
are	O
the	O
lengths	O
of	O
the	O
codewords	O
of	O
,	O
then	O
.	O
</s>
<s>
Examples	O
of	O
prefix	B-Algorithm
codes	I-Algorithm
include	O
:	O
</s>
<s>
Commonly	O
used	O
techniques	O
for	O
constructing	O
prefix	B-Algorithm
codes	I-Algorithm
include	O
Huffman	B-General_Concept
codes	I-General_Concept
and	O
the	O
earlier	O
Shannon	B-Algorithm
–	I-Algorithm
Fano	I-Algorithm
codes	I-Algorithm
,	O
and	O
universal	B-Algorithm
codes	I-Algorithm
such	O
as	O
:	O
</s>
