Implementation of Hoffman encoding algorithm.