Overview
Huffman Coding repeatedly merges the two least frequent symbols or subtrees to build a binary prefix tree. Traversing the tree assigns variable-length codes without ambiguity.
Builds a prefix code that gives shorter bit strings to more frequent symbols.
Compact metadata for implementation and discovery.
Huffman Coding repeatedly merges the two least frequent symbols or subtrees to build a binary prefix tree. Traversing the tree assigns variable-length codes without ambiguity.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n log n)
Average
O(n log n)
Worst
O(n log n)
Space
O(n)
cost = sum(frequency(symbol) * code_length(symbol))Measures the weighted size that the Huffman tree greedily minimizes.
Show low-frequency nodes combining into a Huffman tree.
Huffman coding is optimal among symbol-by-symbol prefix codes for known frequencies.
What each reference supports for this entry.
Textbook reference for the algorithmic family and analysis of Huffman Coding.
Data compression textbook reference for the coding or dictionary method used by Huffman Coding.
Good next jumps from the relationship graph, ranked for useful discovery.
Compression · Foundation
RLE exploits repeated runs while Huffman coding exploits symbol frequencies.
Compare with thisCompression · Core
Adaptive Huffman Coding uses a different compression model or code representation than Huffman Coding.
Compare with thisCompression · Core
Canonical Huffman Coding uses a different compression model or code representation than Huffman Coding.
Compare with thisCompression · Core
FLAC Linear Prediction uses a different compression model or code representation than Huffman Coding.
Compare with thisHuffman coding uses prefix codes, while arithmetic coding can model fractional-bit probabilities more closely.
DEFLATE combines LZ77 with Huffman coding.