Why it matters
Huffman is classic greedy. Understanding shapes compression.
Advertisement
The architecture
Min-PQ by frequency.
Merge two smallest.
Repeat until one tree.
Advertisement
How it works end to end
Prefix code (no code prefix of another).
Minimizes expected code length.
O(n log n) with PQ.