You are on page 1of 3

Lempel-Ziv Compression

- A compression method invented by Lempel - Zip and Welch.


- Works based on a very simple idea that an encoder and a decoder build the
ciphertext together.

Operating principle:
- A character string is a set of two or more characters.
- Remembers all the character strings encountered and assigns it a unique
signature.
- If the string is encountered again, it will be replaced with the sign of the
previous assignment.

Compression rule
1) The first 256 signs are reserved for single characters
2) Compare with "dictionary" when the buffer contains more than 2
characters.
3) The input characters are added to the container buffer until the string in
the container is not in the "dictionary".
4) When the containing buffer contains a string that is not in the
"dictionary", the string in the containing buffer is brought into the
"dictionary". The last character of the string literal in the container
buffer must stay in the container buffer to continue forming a new
string.
Example: encode the string "!BAN!BA!BAA!BAR!"
Run-Length Encoding
- RLE batch data compression is a lossless compression method.
- RLE works by finding a series of consecutive, repeated data in the data
series into another representative data, the purpose is to reduce the size of
the original data.
- Example:

Advantages
- For data with repeated repetitions of a character, this algorithm is very
suitable, significantly reducing the data size.
Defect
- For data types where the information is less repetitive, the use of RLE is not
really efficient, producing data after compression with a larger capacity
than the original data, this is called the reverse effect.
- Example: abcdefgh (8byte) -> a1b1c1d1e1f1g1h1 (16byte)

You might also like