|
|
The algorithm works, and it produces fairly efficient variable-length encodings; when the two smaller sets produced by a partitioning are in fact of equal probability, the one bit of information used to distinguish them is used most efficiently. Unfortunately, Shannon-Fano does not always produce optimal prefix codes; the set of probabilities (.35, .17, .17, .16, .15) is an example of one that will be assigned non-optimal codes by Shannon-Fano.
For this reason, Shannon-Fano is almost never used; Huffman coding is almost as computationally simple and always produces optimal prefix codes -- optimal, that is, under the constraints that each symbol is represented by a code formed of an integral number of bits. This is a constraint that is often unneeded, since the codes will be packed end-to-end in long sequences. In such situations, arithmetic coding can produce greater overall compression than either Huffman or Shannon-Fano, since it can encode in fractional numbers of bits which more closely approximate the actual information content of the symbol. However, arithmetic coding has not obsoleted Huffman the way that Huffman obsoletes Shannon-Fano, both because arithmetic coding is more computationally expensive and because it is covered by multiple patents.