Why ASCII letter A has a Hamming Distance of 3?
-
29-09-2020 - |
Solution
A code is a collection of binary vectors of some length $n$, known as codewords. The Hamming distance between two codewords $x,y$ is the number of positions $i$ such that $x_i \neq y_i$. The minimum distance of a code is the minimum Hamming distance between two different codewords.
For example, the Hamming(7,4) code consists of 16 codewords of length 7:
0000000
1110000
1001100
0111100
0101010
1011010
1100110
0010110
1101001
0011001
0100101
1010101
1000011
0110011
0001111
1111111
You can check that any two codewords differ in either 3 or 4 positions. For example, 1010101 and 0100101 differ in the first 3 positions. Therefore the minimum distance of the code is 3.
There is absolutely no meaning for the Hamming distance of a single codeword. Hamming distance is a property of pairs of codewords.
OTHER TIPS
Tanenbaum is not saying that ASCII character "A" has a particular Hamming distance. Computerphile has a video that may clear things up.
The Hamming distance between two codes is the number of times there is a different bit between them, for example between 1011
and 1111
a Hamming distance of 1.
The example that you're seeing is code correction. When you send anything through a cable there could be some errors (change of bits 1 to 0
or 0 to 1
). So there are some common algorithms that minimise these errors within the domain of Information Theory. In this example they show the binary code of the letter A before and after being received by destination, a Hamming distance of 3 was found means that 3 bits have changed.
I previously implemented some related functions and more details are explained on my GitHub. You can check my git repository if you're interested.