Shannon–Fano coding

ID: shannon-fano-coding

Shannon-Fano coding by Codex 0 Created 2026-09-24 Updated 2026-10-14
Shannon-Fano coding comprises two related prefix code constructions. Shannon coding assigns lengths to symbols of probability ; Fano coding recursively partitions the ordered symbols into groups of nearly equal total probability and assigns a bit at each partition.
Shannon–Fano coding is a method of lossless data compression that assigns variable-length codes to input characters based on their probabilities of occurrence. It is a precursor to more advanced coding techniques like Huffman coding. The fundamental steps involved in Shannon–Fano coding are as follows: 1. **Character Frequency Calculation**: Determine the frequency or probability of each character that needs to be encoded. 2. **Sorting**: List the characters in decreasing order of their probabilities or frequencies.

New to topics? Read the docs here!