In: Computer Science
You want to reduce text communication with your
corrupt friends in Wall Street. You suggest
using Huffman coding to reduce the number of bits in
communication.
You look over your previous 100 words of texts. You find the
following words and their number
of occurrence in parenthesis: SELL (12), BUY (8), MOVE (19), HIDE
(42), STOP (2) and WATCH
(17). This frequency is consistent over all your messages.
(a) What codewords do you recommend for each word?
(b) Whit these codewords, how many bits of communication do you
need when texting 100
words compared to a fixed-length code?
(b) In 100 words text frequencies will be SELL (12), BUY (8),
MOVE (19), HIDE (42), STOP (2) and WATCH
(17). There are 6 words. So, in normal encoding we will need 3 bits
for each word. So, for 100 words we will need 300 bits.
If we use huffman encoding the number of bits needed will be:
12*4 + 8*5 + 19*2 + 42*1 + 2*5 + 17*3 = 229 bits
We can see the considerable amount of saving here.