IronmanX46
IronmanX46

Reputation: 3

Decoding methods for Huffman Encoded Text

Please help me and explain the algorithm to decode Huffman encoded Text. (Explain it in just English)

Thanks and Regards, Larry

Upvotes: 0

Views: 196

Answers (1)

John Kokolakis
John Kokolakis

Reputation: 71

To decode a Huffman Encoded text you would want to use a Huffman tree. The data has been binary encoded so we will go from there.

  • We start from the root. (Iterating through the data) until a leaf is found, for each set of bits, we want to find the corresponding character. If the current bit is 0, that indicates a left node and we move there. If it is 1, we do the same except to the right. If we find a leaf node, we return that character for that node. We then resume iterating through the encoded data.

In essence: 0 = left node, 1 = right node, for each leaf you return that character. You do this from the top to the bottom. I hope this helps!

Upvotes: 1

Related Questions