Huffman Coding
In the following we have analysed some text, and generated the following Huffman Table:
Symbol Weight Huffman Code 287 111 e 167 000 a 95 0101 i 110 1010 n 90 0100 o 106 0111 s 107 1001 t 116 1011 c 43 00101 d 50 01101 h 44 00110 l 70 11010 m 56 10001 p 44 00111 r 84 11011 u 47 01100 b 20 001000 f 23 001001 g 28 110000 y 26 100001 , 18 1100110 . 15 1100010 k 17 1100101 v 15 1100011 w 18 1100111 0 8 11001000 1 6 10000001 ' 5 110010011 - 3 100000001 3 3 100000100 ? 3 100000101 x 4 110010010 2 2 1000001101 5 2 1000001111 9 1 1000000000 j 1 1000000001 ( 1 10000011000 ) 1 10000011001 4 1 10000011100 6 1 10000011101
For example "hello" will be coded as:
00110 000 11010 11010 0111
and as a bit stream:
0011000011010110100111