Skip to content
uencoder

LZ77

LZ77 is the sliding-window dictionary compression algorithm proposed by Lempel and Ziv in 1977, referencing earlier data through (distance, length, literal) triples.

Purpose

It achieves universal lossless compression by exploiting repeated patterns in the data, and is the foundation of DEFLATE, LZSS, LZMA, and more.

Mechanism

Maintain a sliding window (history buffer) plus a look-ahead buffer; find the longest match for the look-ahead within the window, emit either a (distance, length) reference or a literal, then slide the window forward.

Use cases

  • Core of DEFLATE/gzip compression
  • General-purpose file compression
  • Real-time stream compression

Related tools

References