← Back to All Algorithms
📦 Huffman Coding
How It Works (Greedy)
- Create a leaf node for each character with its frequency
- Build a min-priority queue of all nodes
- Extract two nodes with minimum frequency
- Create new internal node with sum of frequencies
- Insert new node back into queue
- Repeat until one node remains (root)
Character Frequencies
Priority Queue
Click "Start" to build Huffman tree
Huffman Codes
| Character |
Frequency |
Code |
Bits Used |