Short answer: Shannon-Fano coding builds a prefix code by sorting symbols by probability and splitting the list into two groups whose total probabilities are as equal as possible. One group gets a leading 0 and the other a leading 1. Each group is split the same way until every…
Category: Compression
How LZW grows a dictionary of phrases
Short answer: LZW compresses by emitting codes for phrases in a dictionary that starts as the alphabet and grows by one new phrase per step. The encoder finds the longest dictionary phrase that matches the upcoming bytes, emits its code, and adds the phrase plus the next input byte…
How LZ77 points back into a sliding window
Short answer: LZ77 compresses a stream by replacing a repeated string with a pointer into a recent window: an offset, a length, and sometimes the next unmatched character. The decoder copies those bytes from the bytes it has already emitted. A match must lie inside the window and behind…
How arithmetic coding narrows a fraction
Short answer: Arithmetic coding encodes a message as a single fraction of the unit interval. Each symbol narrows the current interval to the subinterval proportional to the symbol’s probability. The encoder emits bits as soon as they are determined by the shrinking interval, and it uses renormalization to keep…
