Predict an overlapping copy

Output currently AB. Next token is distance=2, length=5.

Can the decoder take five bytes from the old output?

1 / 5

Advance one byte at a time

AB → ABA → ABAB → ABABA → ABABAB → ABABABA.

Recompute len(output)-2 for every append. Newly produced bytes become valid sources.

Longest match wins, then smallest distance; length below three becomes a literal.

2 / 5

Follow LZW additions

Encode ABABABA from the 256-byte dictionary.

Emit 65, add 256=AB. Emit 66, add 257=BA. Emit 256, add 258=ABA. Emit 258 at end.

3 / 5

Missing-entry prediction

The decoder has previous=AB and nextCode=258 when it receives 258.

Its next entry must be previous+first(previous)=ABA.

The exception permits exactly nextCode, not arbitrary unknown codes.

4 / 5

Transfer task

Decode [90,256]: Z followed by ZZ produces ZZZ.

At size 4096 both dictionaries stop adding. No implicit reset.

Integer code output does not specify variable-width bit packing or a GIF file.

5 / 5
←/→ or click edges to navigate · ? help · N notes · F fullscreen