When we encode using huffman coding method.Should we include spaces into consideration as well?
Asked
Active
Viewed 1,536 times
2
-
2Spaces are just characters, so these are encoded exactly the same way (just like all other characters, like `~`, `@`, `!`, etc.) – Willem Van Onsem Jul 07 '19 at 17:25
-
1Why would you omit any character? That only adds complication. And makes it impossible to decompress to 100% the same text. – H H Jul 07 '19 at 17:43
-
2Ifyouleaveoutthespacesitwillbehardtoreadthedecompressedtext. – rici Jul 07 '19 at 18:09
1 Answers
5
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:

Willem Van Onsem
- 443,496
- 30
- 428
- 555