Skip to main content

Source coding; fixed vs variable length codes

Short answer

Source coding removes redundancy to save bandwidth and storage. Fixed-length codes assign equal bits to all symbols, while variable-length codes give shorter codes to frequent symbols, achieving lower average length. Huffman coding builds an optimal prefix code minimizing average length for given probabilities.

Why is source coding necessary? Differentiate between fixed length codes and variable length codes. What is the purpose of Huffman's coding algorithm?

Why source coding is necessary

Raw data (text, audio, images) contains redundancy, so sending it as it is wastes bandwidth and storage. Source coding removes this redundancy and represents the data with the fewest bits (compression), approaching the source entropy.

Fixed length vs variable length codes

PointFixed-length codeVariable-length code
Code lengthSame for all symbolsDiffers; frequent symbols get shorter codes
Average lengthHigher, ⌈log₂ M⌉ bits for M symbolsLower, close to the entropy
DecodingSimpleNeeds the prefix property
ExampleASCII (7 or 8 bits)Huffman, Morse

Purpose of Huffman coding

Huffman's algorithm builds the optimal prefix (variable-length) code for given symbol probabilities. It gives the shortest average code length, and so the best lossless compression for symbol-by-symbol coding.

✓ Answer checked by Claude Sonnet 5.5

All Data Communication chapter 8 questions →