JOVANA
Explore Library Glossary Getting Started Three Levels Fields How it works Mission
Join the mission
Back to the library
Information Theory 1977

A Universal Algorithm for Sequential Data Compression

Jacob Ziv & Abraham Lempel

Don't repeat yourself — point back to the earlier copy. The idea inside every ZIP.

Choose your version
In depth · the introduction

Every ZIP file, every web page, every PNG image owes its smaller size to one idea from 1977: instead of repeating yourself, point back to where you said it before.

The idea, unpacked

Real data repeats. The same words, the same patterns of code, the same runs of colour in an image — they come back again and again. Lempel and Ziv's insight was that you don't have to store a repeat at all. You can replace it with a tiny note: 'go back this many characters, and copy that many.' A note like that is far smaller than the text it stands in for.

The clever part is that the method learns the repetitions as it reads. It keeps a window onto the recent past, and whenever the text ahead matches something already inside that window, it swaps the match for a pointer. No dictionary has to be prepared in advance, and nothing extra has to be sent alongside — the receiver rebuilds everything from the pointers themselves.

Where it came from

The idea came from two Israeli engineers, Jacob Ziv and Abraham Lempel, working at the Technion in Haifa. Their 1977 paper in the IEEE Transactions on Information Theory laid out the sliding-window method; a 1978 follow-up gave a second version with a cleaner proof. Together the two papers are known simply as 'LZ' — LZ77 and LZ78 — and between them they became the backbone of almost all general-purpose compression. The authors weren't chasing a product; they were after a provably good answer to a theoretical question, and the practical revolution followed.

Why it mattered

Two things made it win. First, it is universal: you can point it at English, at Chinese, at program code, at sensor logs, at an image — anything — with no tuning, and it adapts on its own. Second, it isn't just a clever trick that happens to work; Ziv and Lempel proved it gets close to the theoretical best any compressor could do. 'Works on everything' plus 'provably near-optimal' is a rare combination, and it is exactly why the idea spread into every corner of computing.

An everyday analogy

Think of taking notes in a long meeting. The third time someone says the same long phrase, you don't write it out again — you scribble 'same as above' with an arrow. Or a knitting pattern that says 'repeat rows 2–5 four times' instead of printing twenty rows. LZ77 is that habit, made exact: every repeat becomes a precise arrow saying how far back to look and how much to copy.

An interactive string: preset buttons choose a sample text and a slider sets the window size W; stepping a second slider compresses the text one codeword at a time, highlighting the earlier source run, the copied run, and the next literal, while the list below grows into the full output of (distance, length, letter) codewords; an Expert panel shows the character count, codeword count, and a bit-size estimate before and after.

Where it sits

This is the third corner of a triangle already in this Library. Claude Shannon (1948) proved how small data can be squeezed in principle. David Huffman (1952) found the best way to shrink individual symbols. Lempel and Ziv took on the part neither covered — repeated phrases — and the dominant real-world coder, DEFLATE, runs LZ77 and Huffman back to back, so all three ideas literally cooperate inside the gzip and PNG you use every day.

The original document
Original source text
Jacob Ziv & Abraham Lempel · IEEE Transactions on Information Theory, vol. IT-23, no. 3, pp. 337–343 · May 1977
Abstract
A universal algorithm for sequential data compression is presented. Its performance is investigated with respect to a nonprobabilistic model of constrained sources. The compression ratio achieved by the proposed universal code uniformly approaches the lower bounds on the compression ratios attainable by block-to-variable codes and variable-to-block codes designed to match a completely specified source.
The idea — point back instead of repeat
The algorithm reads the input left to right while keeping a window of the most recently seen symbols. At each step it searches that window for the longest run of symbols that matches what comes next, and replaces that run with a single codeword rather than spelling it out again.
The codeword
Each codeword is a triple: how far back the matching run begins (the pointer p), how long it is (ℓ), and the one new symbol c that breaks the match. Because a match may start inside the window and extend into the symbols still being encoded, a pointer of distance 1 can reproduce a long run of repeats — the algorithm's 'reproducible extension.' Decoding simply replays each copy from the text already reconstructed.
Why 'universal'
The encoder is told nothing about the statistics of the source — no probabilities, no codebook prepared in advance. Yet the paper proves that its compression ratio uniformly approaches the best ratio attainable by codes specially designed for a fully known source. A 1978 companion paper (LZ78) sharpened this into asymptotic optimality against the entropy rate of any stationary, ergodic source.
[ … ]
IEEE Transactions on Information Theory · May 1977