A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/computer-networks/hamming-code-in-computer-network/ below:

Hamming Code in Computer Network

Hamming Code in Computer Network

Last Updated : 14 May, 2025

Hamming code is an error-correcting code used to ensure data accuracy during transmission or storage. Hamming code detects and corrects the errors that can occur when the data is moved or stored from the sender to the receiver. This simple and effective method helps improve the reliability of communication systems and digital storage. It adds extra bits to the original data, allowing the system to detect and correct single-bit errors. It is a technique developed by Richard Hamming in the 1950s.

What is Redundant Bits?

Redundant bits are extra binary bits that are generated and added to the information-carrying bits of data transfer to ensure that no bits were lost during the data transfer. The number of redundant bits can be calculated using the following formula:

 2r ≥ m + r + 1 

where,

Suppose the number of data bits is 7, then the number of redundant bits can be calculated as

= 24 ≥ 7 + 4 + 1 

Thus, the number of redundant bits is 4.

Types of Parity Bits

A parity bit is a bit appended to a data of binary bits to ensure that the total number of 1’s in the data is even or odd. Parity bits are used for error detection. There are two types of parity bits:

Algorithm of Hamming Code

Hamming Code is simply the use of extra parity bits to allow the identification of an error.

Step 1: Write the bit positions starting from 1 in binary form (1, 10, 11, 100, etc).

Step 2: All the bit positions that are a power of 2 are marked as parity bits (1, 2, 4, 8, etc).

Step 3: All the other bit positions are marked as data bits.

Step 4: Each data bit is included in a unique set of parity bits, as determined its bit position in binary form:

Step 5: Since we check for even parity set a parity bit to 1 if the total number of ones in the positions it checks is odd. Set a parity bit to 0 if the total number of ones in the positions it checks is even.

Determining The Position of Redundant Bits

A redundancy bits are placed at positions that correspond to the power of 2. As in the above example:

Determining The Parity Bits According to Even Parity

Error Detection and Correction

Suppose in the above example the 6th bit is changed from 0 to 1 during data transmission, then it gives new parity values in the binary number

For all the parity bits we will check the number of 1's in their respective bit positions.

Features of Hamming Code

For Implementation you can refer this article.

Question on Hamming Code Assume that 12 bit hamming codeword consist of 8 bit data and 4 check bits is d8d7d6d5c4d4d3d2c3d1c2c1 ,where the data bits and the check bits are given in the following tables: [GATE 2021 ]

Which one of the following choices gives the correct values of x and y ?

(A) x is 0 and y is 0

(B) x is 0 and y is 1

(C) x is 1 and y is 0

(D) x is 1 and y is 1

Answer: (A)

We will first insert our codeword according to hamming code d8d7d6d5c4d4d3d2c3d1c2c1,

Now, calculating hamming code according to first parity bit C1: d7d5d4d2d1c1. 1x0010, To make number of 1 even , for this x must be 0.

Similarly, lets calculate for y , we will start from c8 and make its even=>110xy here x is already 0 , so y should be 0.

So the value of x is 0 and y is 0.

For more details you can refer GATE | GATE CS 2021 | Set 1 | Question 39 published quiz.

Advantages Disadvantages

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4