Huffman coding is a lossless compression algorithm that is optimal, assuming all input characters are drawn from a known discrete distribution.
Huffman coding is an algorithm that builds a variable-length, prefix-free code for each character in an alphabet based on the frequency of that character. The algorithm works by greedily assembling an encoding tree by combining together encoding trees for individual characters based on their weights. Low-weight trees are combined together until only a single tree remains.