首页 > 解决方案 > Should we Include spaces in Huffman Coding method

问题描述

When we encode using huffman coding method.Should we include spaces into consideration as well?

标签: algorithmhuffman-code

解决方案


The Huffman coding [wiki] encodes a stream of characters. These characters can include spaces, symbols, emoji characters, characters with diacritics, etc.

So we take spaces into account as well, otherwise if we would decode the string, the decoded string will not contain these spaces anymore.

In fact the Wikipedia article contains an image of a Huffman encoding tree that shows a space, at the righmost leaf:

Huffman encoding image on Wikipedia


推荐阅读