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.

Level: advancedTopic: Data structures algorithms

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

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.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.