Lably
Skip to content

LZ77 and LZ78

Lossless data compression algorithms

  • 10 min read
  • 4 chapters

Related on Lably

Through Algorithm and Pseudocode

They are both theoretically dictionary coders. LZ77 maintains a sliding window during compression. This was later shown to be equivalent to the explicit dictionary constructed by LZ78—however, they are only equivalent when the entire data is intended to be decompressed.

Since LZ77 encodes and decodes from a sliding window over previously seen characters, decompression must always start at the beginning of the input. Conceptually, LZ78 decompression could allow random access to the input if the entire dictionary were known in advance. However, in practice the dictionary is created during encoding and decoding by creating a new phrase whenever a token is output.

The algorithms were named an IEEE Milestone in 2004. In 2021 Jacob Ziv was awarded the IEEE Medal of Honor for his involvement in their development.

Theoretical efficiency

In the second of the two papers that introduced these algorithms they are analyzed as encoders defined by finite-state machines. A measure analogous to information entropy is developed for individual sequences (as opposed to probabilistic ensembles). This measure gives a bound on the data compression ratio that can be achieved. It is then shown that there exists finite lossless encoders for every sequence that achieve this bound as the length of the sequence grows to infinity. In this sense an algorithm based on this scheme produces asymptotically optimal encodings. This result can be proven more directly, as for example in notes by Peter Shor.

Formally, (Theorem 13.5.2 ).

LZ78 is universal and entropic—If X is a binary source that is stationary and ergodic, then lim supn1nlLZ78(X1:n)≤h(X) with probability 1. Here h(X) is the entropy rate of the source.

Similar theorems apply to other versions of LZ algorithm.

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Computing and communication