Shannon-Fano coding (source code)

= Shannon-Fano coding
{c}
{wiki=Shannon–Fano_coding}

Shannon-Fano coding comprises two related <prefix code> constructions. Shannon coding assigns lengths $\lceil-\log_2p_i\rceil$ to symbols of probability $p_i$; Fano coding recursively partitions the ordered symbols into groups of nearly equal total probability and assigns a bit at each partition.