Huffman tree
A Huffman tree is a tree where every path from the root to a leaf represents a prefix-free code for that leaf's corresponding symbol. Symbols are organized in the tree such that those which appear most frequently in the given data have the shortest paths from the root (the shortest encodings). Huffman trees are an application of trees in data compression.
In a system with prefix-free codes, the code for any symbol is never a prefix of another symbol's code. The Huffman code for a symbol is obtained by taking the unique path from the root to that symbol's associated leaf, marking each left with a \(0\), and every right with a \(1.\) For example, in the Huffman tree to the right, the code for \(a\) is \(010.\) You'll find that no other symbol's code in that tree starts with \(010\) because by taking that path, you'll already be at a leaf. To decode \(010\), just follow the path it specifies. The uniqueness of paths in trees maps each code to exactly \(1\) symbol.
Huffman trees give symbols variable-length codes (\(a\) is \(010\), \(t\) is \(0110\), etc.) which tend to require fewer bits to represent than fixed-length codes like in the ASCII or Unicode standards. The space-efficiency of Huffman trees is due to them being tailored to the exact frequencies of the characters in the text they are meant to encode.