<s>
LZ77	B-Algorithm
and	I-Algorithm
LZ78	I-Algorithm
are	O
the	O
two	O
lossless	B-Algorithm
data	I-Algorithm
compression	I-Algorithm
algorithms	O
published	O
in	O
papers	O
by	O
Abraham	O
Lempel	O
and	O
Jacob	O
Ziv	O
in	O
1977	O
and	O
1978	O
.	O
</s>
<s>
These	O
two	O
algorithms	O
form	O
the	O
basis	O
for	O
many	O
variations	O
including	O
LZW	B-Algorithm
,	O
LZSS	B-Algorithm
,	O
LZMA	B-General_Concept
and	O
others	O
.	O
</s>
<s>
Besides	O
their	O
academic	O
influence	O
,	O
these	O
algorithms	O
formed	O
the	O
basis	O
of	O
several	O
ubiquitous	O
compression	O
schemes	O
,	O
including	O
GIF	O
and	O
the	O
DEFLATE	B-Algorithm
algorithm	O
used	O
in	O
PNG	O
and	O
ZIP	B-General_Concept
.	O
</s>
<s>
They	O
are	O
both	O
theoretically	O
dictionary	B-Algorithm
coders	I-Algorithm
.	O
</s>
<s>
This	O
measure	O
gives	O
a	O
bound	O
on	O
the	O
data	B-General_Concept
compression	I-General_Concept
ratio	I-General_Concept
that	O
can	O
be	O
achieved	O
.	O
</s>
<s>
It	O
is	O
then	O
shown	O
that	O
there	O
exists	O
finite	O
lossless	B-Algorithm
encoders	I-Algorithm
for	O
every	O
sequence	O
that	O
achieve	O
this	O
bound	O
as	O
the	O
length	O
of	O
the	O
sequence	O
grows	O
to	O
infinity	O
.	O
</s>
<s>
As	O
this	O
type	O
of	O
pair	O
repeats	O
a	O
single	O
copy	O
of	O
data	O
multiple	O
times	O
,	O
it	O
can	O
be	O
used	O
to	O
incorporate	O
a	O
flexible	O
and	O
easy	O
form	O
of	O
run-length	B-Algorithm
encoding	I-Algorithm
.	O
</s>
<s>
But	O
mirroring	O
the	O
encoding	O
process	O
,	O
since	O
the	O
pattern	O
is	O
repetitive	O
,	O
the	O
read	O
pointer	O
need	O
only	O
trail	O
in	O
sync	O
with	O
the	O
write	O
pointer	O
by	O
a	O
fixed	O
distance	O
equal	O
to	O
the	O
run	B-Algorithm
length	I-Algorithm
LR	O
until	O
L	O
characters	O
have	O
been	O
copied	O
to	O
output	O
in	O
total	O
.	O
</s>
<s>
LZSS	B-Algorithm
improves	O
on	O
LZ77	O
by	O
using	O
a	O
1-bit	O
flag	O
to	O
indicate	O
whether	O
the	O
next	O
chunk	O
of	O
data	O
is	O
a	O
literal	O
or	O
a	O
length	O
–	O
distance	O
pair	O
,	O
and	O
using	O
literals	O
if	O
a	O
length	O
–	O
distance	O
pair	O
would	O
be	O
longer	O
.	O
</s>
<s>
,	O
the	O
most	O
popular	O
LZ77-based	O
compression	O
method	O
is	O
DEFLATE	B-Algorithm
;	O
it	O
combines	O
LZSS	B-Algorithm
with	O
Huffman	B-General_Concept
coding	I-General_Concept
.	O
</s>
<s>
LZW	B-Algorithm
is	O
an	O
LZ78-based	O
algorithm	O
that	O
uses	O
a	O
dictionary	O
pre-initialized	O
with	O
all	O
possible	O
characters	O
(	O
symbols	O
)	O
or	O
emulation	O
of	O
a	O
pre-initialized	O
dictionary	O
.	O
</s>
<s>
The	O
main	O
improvement	O
of	O
LZW	B-Algorithm
is	O
that	O
when	O
a	O
match	O
is	O
not	O
found	O
,	O
the	O
current	O
input	O
stream	O
character	O
is	O
assumed	O
to	O
be	O
the	O
first	O
character	O
of	O
an	O
existing	O
string	O
in	O
the	O
dictionary	O
(	O
since	O
the	O
dictionary	O
is	O
initialized	O
with	O
all	O
possible	O
characters	O
)	O
,	O
so	O
only	O
the	O
last	O
matching	O
index	O
is	O
output	O
(	O
which	O
may	O
be	O
the	O
pre-initialized	O
dictionary	O
index	O
corresponding	O
to	O
the	O
previous	O
(	O
or	O
the	O
initial	O
)	O
input	O
character	O
)	O
.	O
</s>
<s>
Refer	O
to	O
the	O
LZW	B-Algorithm
article	O
for	O
implementation	O
details	O
.	O
</s>
<s>
When	O
the	O
trie-structured	O
dictionary	O
is	O
full	O
,	O
a	O
simple	O
re-use/recovery	O
algorithm	O
is	O
used	O
to	O
ensure	O
that	O
the	O
dictionary	O
can	O
keep	O
adapting	O
to	O
changing	O
data	O
.	O
</s>
