

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Notes for computer systems and some useful insights on Lambda calculus
Typology: Study notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!
The Hamming code is a powerful error correcting code. It enables us to detect errors and to recover the original binary word if one digit goes wrong. Let s = (s 1 , s 2 , s 3 , s 4 ) be a 4-long binary word (i.e., every sj is either 0 or 1). The Hamming code, H(s), of s is a 7-long word defined as follows:
H(s) 1 = H(s) 3 + H(s) 5 + H(s) 7 (mod 2) = s 1 + s 2 + s 4 (mod 2) H(s) 2 = H(s) 3 + H(s) 6 + H(s) 7 (mod 2) = s 1 + s 3 + s 4 (mod 2) H(s) 3 = s 1 H(s) 4 = H(s) 5 + H(s) 6 + H(s) 7 (mod 2) = s 2 + s 3 + s 4 (mod 2) H(s) 5 = s 2 H(s) 6 = s 3 H(s) 7 = s 4
For example, if s = (1, 0 , 0 , 0), then H(s) = (1, 1 , 1 , 0 , 0 , 0 , 0). Indeed,
H(s) 1 = H(s) 3 + H(s) 5 + H(s) 7 (mod 2) = s 1 + s 2 + s 4 (mod 2) = 1 H(s) 2 = H(s) 3 + H(s) 6 + H(s) 7 (mod 2) = s 1 + s 3 + s 4 (mod 2) = 1 H(s) 4 = H(s) 5 + H(s) 6 + H(s) 7 (mod 2) = s 2 + s 3 + s 4 (mod 2) = 0.
In general, we will refer to the bits coming from the original binary word s as data bits, and the rest as parity bits. In the above example, the parity bits are the first two occurrences of 1 and the first occurrence of 0.
Let t be a 7-long binary word such that
We claim that u can be recovered from t. By assumption there is precisely one incorrect bit in t, but we do not know which one. Consider the following algorithm. Let the sequence v consist of the data bits of t and its Hamming code be H(v). There are two cases. Case 1: one data bit ti is incorrect. Then some of the parity bits will be different in t and in H(v). Looking at the definition of the parity bits we can figure out which data bit ti is incorrect. Note also that there are more than one parity bits in t and H(v) which disagree. Case 2: one parity bit ti is incorrect. Then all the other parity bits are correct. Thus changing ti in t yields a binary word such that it is the Hamming code of v. Finally note that cases 1 and 2 can be distinguished by the number of parity bits that differ in t and in H(v). Thus we know which one of the cases apply.
As an example let us look at the binary word t = (1, 1 , 1 , 0 , 0 , 1 , 0). Then v = (1, 0 , 1 , 0) and H(v) = (1, 0 , 1 , 1 , 0 , 1 , 0). Hence the disagreeing parity bits are t 2 = 1 6 = 0 = H(v) 2 and t 4 = 0 6 = 1 = H(v) 4. Thus case 1 above applies and we conclude that we should change t2+4 = t 6.
Indeed, if you take the sequence t = (1, 1 , 1 , 0 , 0 , 0 , 0), it turns out to be the Hamming code of (1, 0 , 0 , 0). Now consider the binary word t = (1, 0 , 1 , 0 , 0 , 0 , 0). Then v = (1, 0 , 0 , 0) and H(v) = (1, 1 , 1 , 0 , 0 , 0 , 0). Thus case 2 applies, and we get the correct Hamming code by changing the second bit in t.