Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Computer Systems Study notes, Study notes of Computer Science

Notes for computer systems and some useful insights on Lambda calculus

Typology: Study notes

2018/2019

Uploaded on 05/09/2019

munshi-premchand
munshi-premchand 🇬🇧

2 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
A Note on Hamming Code
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= (s1, s2, s3, s4) be a 4-long binary word (i.e., every sjis either 0 or 1). The Hamming
code,H(s), of sis a 7-long word defined as follows:
H(s)1=H(s)3+H(s)5+H(s)7(mod 2) = s1+s2+s4(mod 2)
H(s)2=H(s)3+H(s)6+H(s)7(mod 2) = s1+s3+s4(mod 2)
H(s)3=s1
H(s)4=H(s)5+H(s)6+H(s)7(mod 2) = s2+s3+s4(mod 2)
H(s)5=s2
H(s)6=s3
H(s)7=s4
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) = s1+s2+s4(mod 2) = 1
H(s)2=H(s)3+H(s)6+H(s)7(mod 2) = s1+s3+s4(mod 2) = 1
H(s)4=H(s)5+H(s)6+H(s)7(mod 2) = s2+s3+s4(mod 2) = 0.
In general, we will refer to the bits coming from the original binary word sas 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 tbe a 7-long binary word such that
there is no 4-long binary word sfor which t=H(s),
if we change a certain bit in t, then it becomes the Hamming code for some 4-long binary
word u.
We claim that ucan 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 vconsist of the data bits of tand its Hamming code be
H(v). There are two cases.
Case 1: one data bit tiis incorrect. Then some of the parity bits will be different in tand in
H(v). Looking at the definition of the parity bits we can figure out which data bit tiis incorrect.
Note also that there are more than one parity bits in tand H(v) which disagree.
Case 2: one parity bit tiis incorrect. Then all the other parity bits are correct. Thus changing
tiin tyields 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 tand 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 t2= 1 6=0=H(v)2and
t4= 0 6=1=H(v)4. Thus case 1 above applies and we conclude that we should change t2+4 =t6.
1
pf2

Partial preview of the text

Download Computer Systems Study notes and more Study notes Computer Science in PDF only on Docsity!

A Note on Hamming Code

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

  • there is no 4-long binary word s for which t = H(s),
  • if we change a certain bit in t, then it becomes the Hamming code for some 4-long binary word u.

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.