[Verse 1]
Start with symbols, count their weight
Most frequent chars get shorter fate
Build a tree from bottom up
Merge the nodes, frequencies sup
Two smallest values, grab them first
Create a parent, data burst
Left branch zero, right branch one
Codes emerge when tree is done
[Chorus]
Short for common, long for rare
Huffman codes beyond compare
Prefix property, no confusion
Optimal compression, no illusion
Frequencies guide the tree construction
Variable lengths, smart reduction
[Verse 2]
Greedy method, locally best
Priority queue puts nodes to test
Internal nodes hold combined mass
Leaf nodes store the character class
Root to leaf traces the code
Binary digits, custom mode
No code prefix of another
Unambiguous decode, brother
[Chorus]
Short for common, long for rare
Huffman codes beyond compare
Prefix property, no confusion
Optimal compression, no illusion
Frequencies guide the tree construction
Variable lengths, smart reduction
[Bridge]
ASCII wastes eight bits per char
Huffman adapts, travels far
Statistical analysis drives design
Entropy theory, compression fine
Expected length minimized clean
Most efficient lossless machine
[Verse 3]
Decode by traversing down the tree
Zero left, one right, symbols free
Canonical forms standardize the game
Same lengths grouped, lexical name
Transmit the tree or table first
Receiver reconstructs, data burst
Applications span from ZIP to JPEG
Huffman's legacy, compression peg
[Outro]
From frequency counts to binary trees
Optimal codes with elegant ease
David Huffman's brilliant scheme
Variable length compression dream