Adaptive Huffman coding is an improvement over standard Huffman coding that allows the Huffman tree to be adapted as additional symbols are encoded. It determines codeword mappings using a running estimate of symbol probabilities. This allows it to better exploit locality in the data. The algorithm works in two phases: first, it transforms the existing Huffman tree to maintain optimality when a symbol's weight is incremented; second, it increments the weight. This process is repeated as each new symbol is encoded.