We use a standard procedure for predictive coding.
With the help of a copy of
,
an unknown file
can be compressed as follows:
Again,
default characters are inserted at the beginning.
For each character
,
the predictor emits its output
based on the
previous characters.
There will be a
such that
.
The estimate of
is given by
.
The code of
,
,
is generated by feeding
into the
Huffman Coding algorithm
(see below), or, alternatively,
into the
Arithmetic Coding algorithm (see below).
is written into the compressed file.
The basic ideas of both coding algorithms are described
next.