Huffman Encoding

To calculate the original file size, simply multiply the total number of characters by 7 (the number of bits required to represent a character in ASCII).

To calculate the new file size you need to calculate the number of bits required for each character by the frequency of each and add the total together. For example, if the letter B is represented by 1011 in Huffman encoding, and that character appears 5 times, then you multiply 4 (the number of bits) by 5 (the frequency) to get 20 (the bits required for that character. Repeat the process for each character and add these together.

%d bloggers like this: