AI engineering glossary · Data structures algorithms
What is huffman coding?
Huffman coding: A compression method that gives shorter binary codes to frequent symbols and longer codes to rare ones, built greedily by repeatedly merging the two least frequent items into a tree using a priority queue. It produces the best possible prefix code for known frequencies.
Huffman coding: an example
In a text where 'e' is far more common than 'z', 'e' might get a 2-bit code and 'z' a 7-bit code, shrinking the file.
Related terms
More Data structures algorithms terms
- In-place algorithm
- Insertion sort
- Interval scheduling
- Kadane's algorithm
- Knapsack problem
- Knuth-Morris-Pratt algorithm
- Kruskal's algorithm
- Linear search
Where you learn it
Huffman coding is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.