Hamming and Huffman Coding Tutorial By Tom S. Lee Encoding: Hamming and Huffman codes are completely different tools used by computers. Hamming code is an error detecting and correcting tool, while Huffman is a compression tool. Both can be used together, however, to both compress and error detect a message. The following tutorial will show both methods used together. Let's begin by compressing the simple message "codes_are_cool". The first thing we need to do is detect which letters are being used in the message, and their frequency. The list is as follows: c 2/14 o 3/14 d 1/14 e 2/14 s 1/14 _ 2/14 a 1/14 r 1/14 l 1/14 14/14 We then make a tree graph, beginning at the bottom and working our way up. We start with the lowest frequency numbers and combine them to one node. The graph is as follows: Next, we read our codes from the top down (to keep it prefix free) and encode our characters: c 011 o 11 d 0000 e 100 s 0001 _ 010 a 0010 r 0011 l 101 We can now convert our code: 0111100001000001010001000111000100111111101 Now this is our Huffman code, but what about hamming? we must now break this code into byte sized chunks. I will break it down into 4 bit sections: 0111 1000 0100 0001 0100 0111 0001 0011 1111 101 For each section, I need to find the check bits. First set up a table like the following: 0 0 0 0 0 0 0 1 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 0 and every ...