Order source probabilities as , put
and take the first binary digits of as the codeword for symbol . Since for , two cumulative probabilities cannot lie in the same dyadic interval selected by the earlier codeword. The resulting code is prefix-free.
If the Shannon length is and is the length of any binary decipherable code, then
Thus the probability that the Shannon code loses to another code by or more bits decreases exponentially in .

Articles by others on the same topic (1)

Shannon coding, also known as Shannon-Fano coding, is a technique for data compression and encoding based on the principles laid out by Claude Shannon, one of the founders of information theory. It aims to represent symbols of a dataset (or source) using variable-length codes based on the probabilities of those symbols. The primary goal is to minimize the total number of bits required to encode a message while ensuring that different symbols have uniquely distinguishable codes.