## Huffman coding is a statistical data compression technique, which gives a reduction in the average code length, used to represent the symbols of an alphabet. The Huffman code is an example of a code that is optimal in the case where all symbol probabilities are integral powers of 0.5. A Huffman code can be built in the following manner:
1. Rank all symbols in order of probability of occurrence. 2. Successively combine the two symbols of the lowest probability to form a new composite symbol; eventually to build a binary tree where each node is the probability of all nodes beneath it.
3. Trace a path to each leaf, noticing the direction at each node.
## For a given probability distribution, there are many possible Huffman codes, but the total compressed length will be the same. This technique is used in most archivers. This is a means of producing a variable length code which has an average length l close to the average information contained in a message. l will always be greater than or equal to H.
## Thus with known probabilities of occurrence, we can produce an optimum solution using Huffman coding. Huffman coding requires a priori probabilities, which can be a problem in some situations. The Lempel–Ziv algorithm learns the source characteristics whilst coding and is used in situations where the a priori probabilities are not available.
Comments
Post a Comment