Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

*************I need help with this code please explain everything for me to unde

ID: 3865357 • Letter: #

Question

*************I need help with this code please explain everything for me to understand. Thank you.*************

Hamming Codes: Detecting and Correcting Errors Hamming code is a set of error-correction codes that can be used to detect and correct bit errors that can occur when computer data is moved or stored. Hamming Codes-Construction Begin with a 4 bit string. Recall that a bit is a digit which is either zero or one. Call the string a_1 a_2 a_3 a_4. Three check digits, c_1, c_2, and c_3, will be attached to the 4 bit string to produce a 7 bit string. C_1, C_2, and c_3 are chosen as follows: C_1 = 0 if a_1 + a_2 +a_3 is even C_1 = 1 if a_1 + a_2 + a_3 is odd C_2 = 0 if a_1 + a_3 + a_4 is even C_2 = 1 if a_1 + a_3 + a_4 is odd C_3 = 0 if a_2 + a_3 + a_4 is even C_3 = 1 if a_2 + a_3 + a_4 is odd Example: Construct the Hamming code word corresponding to the 4 bit string 0101 a_1 + a_2 + a_3 = 0+1+0 is odd so c1 = 1 a_1 + a_3 + a_4 = 0 + 0+ 1 is odd so c2 = 1 a_2+ a_3 + a_4 = 1 + 0+ 1 is even so c3 = 0 The Hamming code word corresponding to 4 bit string 0101 is 0101110. Find the Hamming code for string 0011

Explanation / Answer

Explanation: Hamming code is used when data is transmitted from one place to another within network. While moving the data bits may be corrupted, to fix this issue we can use many ways, among them Hamming code is one commonly used method. In the given Hamming code Input is considered as 4 bit String. Bits can be either 0 or 1. Here 3 additional bits will be appended with this 4 bit input string while transferring the data and this would make the transferrable data as 7 bit string. How these 3 additional check bits would be attached that will be decided by certain defined rules and these rules should be known to both sender and receiver. Sender would send the data according to the rule and when receiver would receive the data he should check the data according to the rule if he finds that the data is correct then he works with the data else if he finds that the data is not matching according to the rule then he would correct the information bit according to the check bits and the rules.

Let the input 4 bit string is defined as a1a2a3a4 ; and 3 check bits are c1c2c3 and final Hamming word would look like a1a2a3a4c1c2c3 ; all of these 7 bits either can be 0 or 1;

Now when c1 ,c2 and c3 would be 0 and when they would be 1 that will be decided by rules and based upon the value of a1 ,a2 ,a3 and a4 ; so there will be 6 rules as c1 ,c2 and c3 each can have either 0 or 1 value so total 6 values.

The rules are as follows:

Rule 1 : C1 = 0 if a1 + a2 + a3   is even

Rule 2 : C1 = 1 if a1 + a2 + a3   is odd

Rule 3 : C2 = 0 if a1 + a3 + a4   is even

Rule 4 : C2 = 1 if a1 + a3 + a4   is odd

Rule 5 : C3 = 0 if a2 + a3 + a4   is even

Rule 6 : C3 = 1 if a2 + a3 + a4   is odd

Example explanation: Given 4 bit input string is 0101; so According to assumption a1 =0, a2 =1, a3 =0 and a4 =1;

So to construct the check bits c1 ,c2 and c3 we have to follow the rules given above;

Now a1 + a2 + a3 = 0 + 1 + 0 which is odd in terms of number of 1s so set c1 = 1;

Again to find check bit c2 calculate: a1 + a3 + a4 = 0 + 0 + 1; which is odd in terms of number of 1s so set c2 = 1;

Calculate c3 : a2 + a3 + a4 = 1 + 0 + 1; which is even in terms of number of 1s so set c3 = 0;

So c1c2c3 would be 110 and that will be appended with input bit string 1010 and final Hamming word would become 1010110 for input bit string 1010.

Now we can easily solve the Question 1:

Find the hamming code for string 0011 :

Let the input 4 bit string is defined as a1a2a3a4 so in the given problem a1 =0, a2 =0, a3 =1 and a4 =1;

So to construct the check bits c1 ,c2 and c3 we have to follow the rules given above;

Computation of c1 : a1 + a2 + a3 = 0 + 0 + 1 which is odd in terms of number of 1s so set c1 = 1;

Computation of c2 : a1 + a3 + a4 = 0 + 1 + 1 which is even in terms of number of 1s so set c2 = 0;

Computation of c3 : a2 + a3 + a4 = 0 + 1 + 1 which is even in terms of number of 1s so set c3 = 0;

So c1c2c3 would be 100 and that will be appended with input bit string 0011;

Now the final Hamming word would become 0011100 for input bit string 0011.

/*Hope this explanation would help you. Thank you!! */