1. Gyanastra
  2. Digital Logic
  3. Error Detection and Correction
  4. Hamming Code: Single-Bit Error Correction and Number of Parity Bits
Free lesson, no account needed 5 min read 3 practice questions after it
Asked in past papers2 times
  • UGC NET20152013

Digital Logic · Error Detection and Correction

Hamming Code: Single-Bit Error Correction and Number of Parity Bits

Overview

Hamming code is a single-bit error correction code: it can detect and correct an error in one bit of a transmitted word.
It works by adding redundant parity bits to the message bits, with the number of parity bits chosen so that every possible single-bit error position and the no-error case can be distinguished.

Key concepts

  • Hamming code: a single-bit error correction code that detects and corrects an error in one bit of the transmitted word.
  • Why only single-bit: a one-bit error is the most frequently occurring error, and the probability that more than one bit gets corrupted is very low.
    The design assumption is therefore at most one bit error (two bits will not get corrupted).
  • Message bits (MM): the actual data to be transmitted.
  • Parity bits (PP): bits added to the MM message bits. They are redundant — they carry no message information and are useful only for error correction.
  • Transmitted word: the total bits sent, equal to M+PM + P.
  • Role of each parity bit: each of the PP parity bits is assigned responsibility for some selected message bits. If anything goes wrong in those selected bits, that parity bit indicates "one of these has got corrupted."

How it works

  1. Let the actual data to be transmitted have MM bits.
  2. Add PP parity bits to these MM bits; the PP bits are redundant and used only for error correction.
  3. The total transmitted word is M+PM + P bits.
  4. At the receiver, the cases to distinguish are:
    • No error at all → 1 case.
    • Exactly one bit corrupted → any one of the M+PM + P bit positions may be the corrupted one → M+PM + P cases.
    • Total cases = (M+P)+1(M + P) + 1.
  5. Each case must be identified separately. The PP parity bits give 2P2^P distinct combinations, so these must be at least as many as the number of cases: 2P≥M+P+12^P \ge M + P + 1.
  6. Choose the smallest PP satisfying this, because sending more redundant parity bits than necessary is undesirable.
  7. Each parity bit is given charge of a subset of message bits; a mismatch flags corruption among its assigned bits.

Formulas

  • 2P≥M+P+12^P \ge M + P + 1
    • MM = number of message (data) bits
    • PP = number of parity (redundant) bits
    • M+PM + P = total transmitted bits
    • M+P+1M + P + 1 = total cases to handle (all single-bit error positions plus the no-error case)
    • 2P2^P = number of combinations available from PP parity bits
  • Total transmitted length =M+P= M + P

Worked examples

Find PP for M=4M = 4 message bits.

  • Total bits transmitted =4+P= 4 + P.
  • Cases to handle =(4+P)= (4 + P) single-bit-error cases +1+ 1 no-error case =P+5= P + 5.
  • Condition: 2P≥P+52^P \ge P + 5.
  • Test smallest values of PP:
PP2P2^PP+5P + 5Satisfied?
126No
247No
388Yes
  • So P=3P = 3 parity bits are needed for 4 message bits.
  • Total transmitted word =4+3=7= 4 + 3 = 7 bits.
  • With 7 bits, the cases are: error in bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, or no error → 8 cases.
  • Since 3 parity bits give 23=82^3 = 8 combinations, each combination represents exactly one case, so all 8 cases are handled.

Revision summary

  • Hamming code performs single-bit error correction; the assumption is at most one bit error.
  • Parity bits are redundant and exist only for error correction.
  • Find the number of parity bits from 2P≥M+P+12^P \ge M + P + 1, choosing the smallest PP.
  • For M=4M = 4: P=3P = 3, total word length 7 bits, handling 8 cases (7 error positions + no error).
  • Each parity bit is given charge of a subset of message bits; a mismatch flags corruption among its assigned bits.
  • Shortcut: For M=4M = 4, check P=1,2,3P = 1, 2, 3 in order against 2P≥P+52^P \ge P + 5; the first PP that satisfies it (here 3) is the answer.

Previous-year exam insights

  • In Hamming code, parity bits are placed at positions that are powers of 2 (1, 2, 4, 8, ...) in the transmitted word, counting positions from 1; all other positions hold message bits.
    Asked inUGC NET 2015
  • The syndrome (the set of check-bit mismatches read as a binary number, with the parity bit at position 2k2^{k} giving bit k) directly gives the position of the erroneous bit; a syndrome of all zeros means no error.
    Asked inUGC NET 2015
  • To correct a single-bit error, flip the bit at the position indicated by the syndrome; the corrected word then yields the original data bits from the non-power-of-2 positions.
    Asked inUGC NET 2015
  • Each parity bit at position 2k2^{k} is computed over all bit positions whose binary index has the k-th bit set (including the parity bit itself), using even parity by convention.
    Asked inUGC NET 2015
  • Hamming code with minimum Hamming distance 3 can correct any single-bit error, or alternatively detect (but not correct) any double-bit error, but not both at once (a double error would be miscorrected as a single error); with an extra overall parity bit (extended Hamming, distance 4) it can correct single errors and detect double errors (SECDED).
  • The number of parity bits needed grows logarithmically: for M data bits the smallest P with 2P≥M+P+12^{P} \ge M + P + 1 gives total word length M + P, e.g. M=8 needs P=4 (12 bits), M=16 needs P=5 (21 bits).
Pages 1–2 of 2