In Huffman coding, a frequency table is a type of data structure that stores the frequencies of characters (or symbols) present in the input data. It is used as a reference to determine the frequency of each character and construct the Huffman tree, which is the basis for generating variable-length codes for each character.
The frequency table typically associates each character with its corresponding frequency or occurrence count in the input data. The frequency of a character represents how often it appears in the data. The table can be implemented using various data structures such as an array, dictionary, or any other suitable data structure depending on the programming language and requirements.
In the following explanation on how to build a frequency table, we will use an example as well to better understand the concept.
Let’s suppose we have an input string.
Input string: "ABRACADABRA"
The first step is character frequency count and the creation of a frequency table.
Character frequency count:
occurs 5 times.
occurs 2 times.
occurs 2 times.
occurs 1 time.
occurs 1 time.
Frequency table:
: 5
: 2
: 2
: 1
: 1
Following are the binary codes assigned through the huffman tree that was designed.
This completes the process of making a frequency table for Huffman coding.
Free Resources