Fundamentals of error correction, Hamming codes, CRC
Hamming distance and what a code can detect or correct, linear block codes with generator and parity-check matrices, Hamming codes with syndrome decoding, and CRC encoding by modulo-2 polynomial division.
CRC treats a bit string as a polynomial and divides it by the generator.
Concept notes
1. Hamming distance and error capability
The Hamming weight of a codeword is its number of 1s. The Hamming distance is the number of positions where and differ, which equals .
The minimum distance of a code is the smallest distance between any two distinct codewords. It decides everything:
Goal
Condition
Detect up to errors
Correct up to errors
Correct and detect () together
So errors can be corrected and detected.
Intuition: correction picks the nearest codeword. If spheres of radius around codewords do not overlap, every pattern of or fewer errors still lies closest to the transmitted codeword.
Single parity bit (even parity): . It detects any odd number of errors and corrects none.
For a linear code, equals the smallest weight of a non-zero codeword, so you need not compare all pairs.
2. Linear block codes
An block code maps message bits to an -bit codeword by adding parity bits. There are codewords; the code rate is .
The code is linear if the XOR of any two codewords is a codeword. The all-zero word is always a codeword.
Systematic form. With generator matrix (), the codeword is : the message followed by the parity bits. The parity-check matrix is (), and every codeword satisfies .
Syndrome decoding. For a received word :
The syndrome depends only on the error pattern. means no detectable error. For a single error in position , equals the -th column of .
There are syndromes, so a code can correct at most distinct non-zero error patterns. This gives the Hamming bound for a -error-correcting code:
A code that meets it with equality is perfect; Hamming codes are perfect for .
3. Hamming codes
A Hamming code with parity bits has
so it corrects any single error (or detects up to two, if used only for detection). Examples: , , .
To protect data bits with single-error correction, the number of parity bits must satisfy
(every one of the single-error positions, plus "no error", needs its own syndrome).
Position scheme (7, 4). Number the bits 1 to 7. Parity bits sit at the powers of two: positions 1, 2, 4. Data bits sit at 3, 5, 6, 7. With even parity:
checks positions 1, 3, 5, 7 (binary index has bit 0 set).
checks positions 2, 3, 6, 7 (bit 1 set).
checks positions 4, 5, 6, 7 (bit 2 set).
At the receiver, recompute the three checks . Read as a binary number, the syndrome is the position of the error; 000 means no error.
Extended Hamming code: add one overall parity bit, giving with . It corrects single errors and detects double errors at the same time (SEC-DED), used in computer memories.
Hamming (7,4) with even parity: each circle is one parity check. Positions 3, 5, 6, 7 carry data; 1, 2, 4 carry parity
4. Cyclic redundancy check (CRC)
A CRC is an error-detecting code. Bits are read as polynomial coefficients: . Sender and receiver agree on a generator polynomial of degree ( bits).
Encoding:
Append zeros to the message: .
Divide by using modulo-2 long division (XOR, no carries).
The -bit remainder is the CRC. Send , i.e. the message followed by the remainder.
The transmitted word is exactly divisible by . The receiver divides what it gets by : a non-zero remainder means an error.
What a CRC detects (with a degree- generator whose and terms are both present):
Error type
Detected?
All single-bit errors
Yes
All burst errors of length
Yes
All odd numbers of bit errors
Yes, if is a factor of
All double errors
Yes, for suitable and frame length
Errors that are a multiple of
No (undetected)
CRC only detects; correction is done by retransmission (ARQ). Hamming codes and other block codes are used when the receiver must correct errors itself (FEC).
Formulas to remember
Hamming distance
Errors detectable
Errors correctable
Code rate
Encoding and check
Hamming code parameters
Parity bits for single-error correction
Hamming bound
CRC transmitted word
Common mistakes
Using t = d_min − 1 for correction; that is the detection limit. Correction is ⌊(d_min − 1)/2⌋.
Forgetting to append r zeros (r = degree of G, one less than the number of generator bits) before the CRC division.
Doing ordinary subtraction with borrows in CRC division; modulo-2 division uses XOR only.
Reading the Hamming syndrome in the wrong bit order; with checks c4 c2 c1, the number c4c2c1 in binary is the error position.
Checking 2^m ≥ k + m instead of 2^m ≥ k + m + 1; the extra 1 is the no-error syndrome.
Finding d_min of a non-linear code from the minimum weight; that shortcut holds only for linear codes.
Worked examples
Try each step yourself, then reveal the working.
Example 1: Encoding 1011 with Hamming (7,4)
numerical
Encode the data bits with the (7,4) Hamming code, using even parity and the position scheme (parity at 1, 2, 4; data at 3, 5, 6, 7).
Step 1: Place the data bits.
Try it on paper first.
Example 2: Correcting a single error with the syndrome
numerical
The (7,4) codeword is received as . Find the syndrome, the error position and the corrected data bits.
10 questions: up to 3 official PYQs and original practice questions, with GATE marking (MCQ wrong answers lose marks). Score 60% or more to pass. A new set is drawn each time.
Mark as mastered
Loading your progress…
My revision notes
Notes written by the GATEiit team against the official GATE EC syllabus; being checked by a reviewer. Updated 2026-11-28. Spotted a mistake? Use Report an issue on any question, or contact us.