Computer Networks · TEE · practice

How a Hamming code locates a single error

Unit 3 · Errors, block coding and CRC · optional practice

Optional extension · no matching calculation in the two supplied papers

Optional worked extension. This calculation format was not found in the supplied December 2025 final or February 2026 re-exam. The numbers and practice marks are authored. Study the core concept and actual-paper questions first; this is extra explanation, not a TEE prediction.

Practice question. Explain the construction and single-error correction of a Hamming code. State the redundancy condition. [5 practice marks]

Answer

A basic binary Hamming code uses parity checks whose outcomes identify a single incorrect bit. For m data bits and r check bits, choose the smallest r satisfying 2r ≥ m+r+1. The syndrome must represent each of the m+r possible single-error positions and the no-error state.

2^r\ge m+r+1LaTeX: 2^r\ge m+r+1
  1. Number positions starting at 1. Put parity bits at powers of two: 1,2,4,8,…; fill other positions with data in the stated order.
  2. Parity bit 1 checks positions whose binary index ends in 1; parity bit 2 checks positions with the 2s bit set; parity bit 4 checks positions with the 4s bit set. Use one declared even/odd parity convention throughout.
  3. For even parity, choose each check bit so its covered positions XOR to zero.
  4. At reception, repeat each parity check. Read syndrome bits with the largest parity position first; the resulting integer is the error position under the single-error assumption. Flip that bit.
  5. A basic Hamming code has distance 3. An additional overall parity bit creates the familiar SECDED extension: single-error correction and double-error detection. Do not claim that basic syndrome correction safely corrects two errors.
Swipe across the diagram to read its labels ↔
Hamming (7,4): even parity, positions left to right
Diagram: Hamming (7,4): even parity, positions left to right. Labels: Hamming (7,4): even parity, positions left to right | Hamming (7,4): even parity, positions left to right | p1 | 0 | 1 | p2 | 1 | 2 | d1 | 1 | 3 | p4 | 0 | 4 | d2 | 0 | 5 | d3 | 1 | 6 | d4 | 1 | 7 | p1: 1,3,5,7 p2: 2,3,6,7 p4: 4,5,6,7 | Data 1011 → codeword 0110011. Bit 5 flips → syndrome 101₂. | Binary 101 = 5: flip bit 5 back, assuming one error.
Positions 1, 2 and 4 hold parity bits in Hamming (7,4).

Yaad rakho: Parity powers of two; syndrome binary tells the position.