Explore BrainMass

Data encoding and decoding using Huffman codes

Using the Huffman code given in the attached image,

(a) encode the string "NEEDLE".
(b) decode the bit string "01111001001110".


Solution Preview

(a) To find the Huffman code for a letter, we need to put together the edge labels in order of traversal from root to the leaf node marked with the respective letter.

Which gives ...

Solution Summary

Solution also explains the process, following which you can easily handle other string encoding and bit string decoding problems with huffman code tree.