---
title: "Hamming codes and their properties"
subject: "Data Communication"
chapter: 8
key: "semester_5/data_communication:hamming-code-properties"
source: https://www.bctengineer.com/q/semester_5/data_communication/hamming-code-properties
site: BCT Engineering
---

# Hamming codes and their properties

Data Communication · Chapter 8: Information Theory and Coding

- Asked in: 2072 Chaitra, 2+4+4 marks
- Video: [Hamming Code | Error Detection](https://www.youtube.com/watch?v=1A_NcXxdoCc) — Neso Academy
- Answer checked by Claude Sonnet 5.5 on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/data_communication/hamming-code-properties
- Whole chapter: https://www.bctengineer.com/md/semester_5/data_communication/chapter-8

## Question

What are Hamming codes? Write the properties of Hamming codes. Visualize a 3-bit code words as code vector.

## Short answer

Hamming codes are perfect linear block codes with d_min=3, correcting single-bit errors. For r parity bits, n=2^r-1, k=n-r. 3-bit words form a cube; repetition code {000,111} has d_min=3, even-parity code detects 1 error.

## Answer

#### Hamming codes
**Hamming codes** are linear block codes that can detect up to two-bit errors and correct all single-bit errors. For r ≥ 2 parity bits the code is (n, k) = (2ʳ − 1, 2ʳ − 1 − r), e.g. (7,4) and (15,11). The parity bits are placed at positions 1, 2, 4, 8, … and each checks the positions that contain it in their binary index.

#### Properties
- Block length n = 2ʳ − 1 and k = n − r data bits; rate k/n = 1 − r/n approaches 1 for large r.
- Minimum Hamming distance d_min = 3: detects 2 errors or corrects 1 error.
- They are **perfect codes**: all 2ⁿ words lie within distance 1 of exactly one codeword.
- Linear (sum of codewords is a codeword), and can be made cyclic.
- Syndrome decoding: the r-bit syndrome gives the exact position of a single-bit error (0 = no error).
- Adding an overall parity bit gives an extended Hamming code with d_min = 4 (single-error correction, double-error detection).
- Simple to implement with XOR gates; used in ECC memory.

#### Visualising 3-bit words as code vectors
All 3-bit words are the 8 vertices of a cube; the Hamming distance between two words is the number of edges on the shortest path between them.

```text
       011 ---------- 111
       /|             /|
      / |            / |
    010 ---------- 110 |
     |  001 -------|-- 101
     | /           | /
     |/            |/
    000 ---------- 100
```
- Repetition code {000, 111}: the two vertices are 3 edges apart, d_min = 3, corrects 1 error (any word one step from 000 decodes to 000, one step from 111 decodes to 111).
- Even-parity code {000, 011, 101, 110}: every pair is 2 edges apart, d_min = 2, detects 1 error but cannot correct it.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What can a Hamming code do?
   A. Detect up to two-bit errors and correct all single-bit errors
   B. Correct all two-bit errors
   C. Only detect single-bit errors
   D. Correct burst errors of any length
   Answer: A. Hamming codes have d_min = 3, so they detect up to two-bit errors and correct single-bit errors. (Key point: Hamming code capability)

2. For r parity bits, what are n and k of a Hamming code?
   A. n = 2r, k = r
   B. n = 2^r - 1, k = 2^r - 1 - r
   C. n = r^2, k = r
   D. n = 2^r, k = 2^r - r
   Answer: B. A Hamming code has n = 2^r - 1 and k = n - r, e.g. (7,4) for r = 3. (Key point: Block length)

3. What does the syndrome of a received Hamming word indicate?
   A. Number of errors in the word
   B. Position of a single-bit error (0 means no error)
   C. The parity of the data bits only
   D. The code rate
   Answer: B. The r-bit syndrome read as a binary number gives the position of the erroneous bit, 0 meaning no error. (Key point: Syndrome decoding)

4. On the cube of 3-bit words, what is the repetition code {000, 111}'s d_min and what does that mean?
   A. d_min = 1, no protection
   B. d_min = 2, detects 1 error only
   C. d_min = 3, corrects 1 error
   D. d_min = 3, corrects 2 errors
   Answer: C. 000 and 111 are opposite corners, 3 edges apart, so d_min = 3 and any single-error word decodes to the nearer codeword. (Key point: Cube representation)

## Related in Data Communication

- [(6,3) block code words, weights, dmin](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Ablock-code-63-matrix-weights) — Data Communication, chapter 8
- [Short note: Hamming codes](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Ahamming-codes-short-note) — Data Communication, chapter 8
- [All code words of the (6,3) code with given G](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Ablock-code-63-all-codewords) — Data Communication, chapter 8
- [Construct a (7,4) Hamming code](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Ahamming-74-construct) — Data Communication, chapter 8
- [Forward error correction using Hamming code](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Afec-hamming) — Data Communication, chapter 8
- [Trellis decoding of 1/2 rate conv. code (3-bit errors)](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Aconv-trellis-3bit) — Data Communication, chapter 8, asked 2×

## Related in other subjects

- [Speech characteristics and 7-bit Hamming code](https://www.bctengineer.com/question.md?key=semester_7%2Fwireless_communication%3Aspeech-hamming-code) — Wireless Communication, chapter 6
- [Hamming weight and distance; (7,4) cyclic code for 1011](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Ahamming-weight-cyclic-1011) — Communication Systems, chapter 8, asked 2×
- [Hamming distance and weight; (6,3) code check for 100101](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Ahamming-6-3-h-100101) — Communication Systems, chapter 8
- [Hamming weight and distance; validate code 100011](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Ahamming-6-3-h-100011) — Communication Systems, chapter 8
