L
LLLOS.ai
Learn
L

Ask Your Tutor · Computer Science

Can you give an example of a real error correction code?

From NCERT Asked by Anonymous from Dallas, United States 23 Oct 2026, 7:16 PM IST Updated

In one line

A real error correction code is the Hamming code, which can find and fix single-bit errors in data.

Richard Hamming — American mathematician and information theorist (1915–1998)
Richard Hamming — American mathematician and information theorist (1915–1998)
Richard Hamming, who invented the Hamming code in 1950 to fix errors in data transmission.
Image: Wikipedia

The rule

Error correction codes add extra bits to data, so mistakes can be found and fixed when the data is received.

For Hamming code (7,4):

  • 4 data bits + 3 parity bits = 7 bits sent.
  • Each parity bit checks a different set of data bits.
The formula
7 bits = 4 data bits + 3 parity bits
7 bitstotal bits sent
4 data bitsactual information
3 parity bitserror-checking bits

Let's understand it simply

Imagine you are sending a message to your friend using paper chits. But you worry a letter might get smudged. So, you add some extra clues (like hints) at the end of your message. If your friend sees a mistake, they use your clues to guess what the correct letter was.

Hamming code does the same. It adds extra bits (called parity bits) to your data. If one bit gets changed by mistake, the code helps the receiver spot where the error is and fix it.

How it works

  1. Write your 4 data bits (for example: 1 0 1 1).
  2. Add 3 parity bits in certain positions (positions 1, 2, and 4).
  3. Each parity bit checks a different set of data bits (using even or odd count of 1s).
  4. Send all 7 bits together.
  5. If one bit changes during transmission, the receiver checks the parity bits to find which bit is wrong.
  6. The receiver flips that bit back to correct the error.
How Hamming Code Works
  1. Write 4 data bits
  2. Add 3 parity bits in positions 1, 2, 4
  3. Calculate parity bits based on data bits
  4. Send all 7 bits
  5. Receiver checks parity to find any single-bit error
  6. Correct the error if found

The story behind it

Richard Hamming, an American mathematician, invented the Hamming code in 1950. He worked at Bell Labs and wanted to fix errors in data sent over telephone lines. He was frustrated when his computer jobs failed due to tiny mistakes, so he created a way for machines to fix errors automatically.

Where you see it in real life

  • CDs and DVDs: Hamming codes help fix scratches and dust errors on discs.
  • RAM in computers: Some memory chips use Hamming code to catch and fix single-bit errors.
  • Satellite communication: Data sent from satellites uses error correction to survive noise in space.
  • Mobile phones: When you call someone, error correction helps your voice sound clear even if the signal is weak.
  • Bank ATMs: Codes help make sure the numbers in your transaction are correct.

Why it matters

  • Keeps your data safe from small mistakes during transfer.
  • Used in almost every digital device — phones, computers, satellites.
  • Helps prevent money loss, miscommunication, and system crashes.
  • Forms the base for more advanced codes used in internet and mobile networks.

Worked example

Let's encode 4 bits: 1 0 1 1 using Hamming (7,4):

Given: Data bits = D1=1, D2=0, D3=1, D4=1
Step 1: Place data and parity bits: _ _ D1 _ D2 D3 D4
Step 2: Fill in data bits: _ _ 1 _ 0 1 1
Step 3: Calculate parity bits:
  P1 (bit 1) checks bits 1,3,5,7: P1, D1, D2, D4 → P1 + 1 + 0 + 1 (must be even)
      P1 + 1 + 0 + 1 = P1 + 2 → P1 = 0 (since 2 is already even)
  P2 (bit 2) checks bits 2,3,6,7: P2, D1, D3, D4 → P2 + 1 + 1 + 1 = P2 + 3 (must be even)
      P2 = 1 (to make total even)
  P3 (bit 4) checks bits 4,5,6,7: P3, D2, D3, D4 → P3 + 0 + 1 + 1 = P3 + 2 (must be even)
      P3 = 0
Step 4: Final code: P1 P2 D1 P3 D2 D3 D4 = 0 1 1 0 0 1 1

Common mistakes

  • Mixing up which bits are data and which are parity.
  • Forgetting to use the correct parity rule (even or odd).
  • Thinking Hamming code can fix two errors at once (it only fixes one).
  • Not recalculating parity bits after correcting an error.

Remember it

Hamming code = data bits + extra check bits; can fix one mistake all by itself.

Check yourself

What is the main purpose of a Hamming code?

To detect and correct single-bit errors in data.

Why do we add parity bits in Hamming code?

Parity bits help us find out where an error happened so we can fix it.

Can Hamming code fix two errors at the same time?

No, it can only correct one error at a time.

Name one device where Hamming code is used.

In computer RAM to fix memory errors.

Quick recap

  • Hamming code is a real error correction code used in computers and CDs.
  • It adds extra bits (parity bits) to help find and fix single-bit errors.
  • Used in RAM, CDs, satellites, and mobile phones.
  • Can only correct one error at a time.
  • Invented by Richard Hamming in 1950.
Written by the LLOS.ai tutor, checked against NCERT chapters. Asked by Anonymous from Dallas, United States on 23 Oct 2026, 7:16 PM IST