LZ78 is a lossless compression algorithm to reduce the size of a repetitive string.

This is done with a dictionary, where previously captured fields can be referenced by their positional index.

Indexes start at ZERO (0)

To decode the codeword (0, c)(0, a)(2, a)(3, b)(4, c)(4, b), start with the empty dictionary.

outputnew dictionary entry
c1. c
a2. a
aa3. aa
aab4. aab
aabc5. aabc
aabb6. aabb

The decoded text is caaaaabaabcaabb