---
title: "Hamming weight/distance; validate x = 0111000 with given H"
subject: "Communication Systems"
chapter: 8
key: "semester_6/communication_systems:hamming-code-vector-0111000"
source: https://www.bctengineer.com/q/semester_6/communication_systems/hamming-code-vector-0111000
site: BCT Engineering
---

# Hamming weight/distance; validate x = 0111000 with given H

Communication Systems · Chapter 8: Error Detection and Correction Coding

- Asked in: 2072 Chaitra (CS II), 2+4 marks; 2071 Chaitra (CS II), 2+4 marks (asked 2 times)
- Video: [Linear block Code | solution of previous year paper | ITC | Parity check matrix H | Code vectors](https://www.youtube.com/watch?v=fp9CyjgOG4I) — Techno Tutorials ( e-Learning)
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/communication_systems/hamming-code-vector-0111000
- Whole chapter: https://www.bctengineer.com/md/semester_6/communication_systems/chapter-8

## Question

Define Hamming weight and Hamming distance for a code vector x = (0111000) and the parity check matrix H given below. Prove that, the given code is valid.
H = [1 1 1 0 1 0 0; 1 1 0 1 0 1 1; 1 0 1 1 0 0 1] (3×7)

## Short answer

Hamming weight of x=(0111000) is 3. Hamming distance from all-zero is 3. Validity: syndrome s = H x^T = sum of columns 2,3,4 of H = (0,0,0)^T, so x is a valid codeword.

## Answer

#### Hamming weight

The **Hamming weight** $w(\mathbf{x})$ of a code vector is the number of 1s in it. For $\mathbf{x}=(0111000)$:

$$
w(\mathbf{x})=0+1+1+1+0+0+0=3
$$

#### Hamming distance

The **Hamming distance** between two code vectors is the number of positions in which they differ, $d(\mathbf{x},\mathbf{y})=w(\mathbf{x}\oplus\mathbf{y})$. For example, distance of $\mathbf{x}$ from the all-zero codeword is $d(0111000,0000000)=3$, and from $\mathbf{y}=1111111$ it is $w(1000111)=4$.

#### Proof that x is a valid codeword

A vector is a valid codeword of the code if and only if its syndrome is zero:

$$
\mathbf{s}=H\mathbf{x}^T=\mathbf{0}\quad(\text{equivalently } \mathbf{x}H^T=\mathbf{0})
$$

$$
H=\begin{bmatrix}1&1&1&0&1&0&0\\1&1&0&1&0&1&1\\1&0&1&1&0&0&1\end{bmatrix},\qquad \mathbf{x}^T=\begin{bmatrix}0\\1\\1\\1\\0\\0\\0\end{bmatrix}
$$

Only positions 2, 3 and 4 of $\mathbf{x}$ are 1, so $H\mathbf{x}^T$ is the modulo-2 sum of columns 2, 3 and 4 of $H$:

| Row | Col 2 | Col 3 | Col 4 | Sum (mod 2) |
|---|---|---|---|---|
| 1 | 1 | 1 | 0 | $1+1+0=0$ |
| 2 | 1 | 0 | 1 | $1+0+1=0$ |
| 3 | 0 | 1 | 1 | $0+1+1=0$ |

$$
\mathbf{s}=H\mathbf{x}^T=\begin{bmatrix}0\\0\\0\end{bmatrix}
$$

Since the syndrome is the zero vector, $\mathbf{x}=(0111000)$ satisfies all three parity-check equations. **Hence the given code vector is valid.**

## Check yourself

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

1. What is the Hamming weight of x = 0111000?
   A. 1
   B. 3
   C. 4
   D. 7
   Answer: B. There are three 1s in 0111000. (Key point: Hamming weight)

2. How is the Hamming distance between two vectors found, and what is d(0111000, 1111111)?
   A. Weight of their XOR; 1000111 gives 4
   B. Weight of their AND; gives 3
   C. Sum of the two weights; gives 10
   D. Weight of their XOR; gives 3
   Answer: A. d(x,y) = w(x XOR y); 0111000 XOR 1111111 = 1000111, which has weight 4. (Key point: Hamming distance)

3. How do you prove x is a valid codeword of the code with parity check matrix H?
   A. Show H x^T = 0 (syndrome is the zero vector)
   B. Show x has even weight
   C. Show x H is the identity
   D. Show H x^T equals x
   Answer: A. A vector is a codeword if and only if its syndrome H x^T is zero. (Key point: Validity test)

4. Since x has 1s in positions 2, 3 and 4, how is H x^T computed and what is the result?
   A. Sum of columns 2, 3, 4 of H mod 2, which gives (0,0,0)
   B. Sum of rows 2, 3, 4 of H, which gives (1,1,1)
   C. Sum of columns 1, 5, 6, 7, which gives (0,0,0)
   D. Sum of columns 2, 3, 4 of H, which gives (1,0,1)
   Answer: A. Each row gives 1+1+0 = 0, 1+0+1 = 0, 0+1+1 = 0, so the syndrome is zero and the code vector is valid. (Key point: Computing the syndrome)

## Related in Communication Systems

- [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
- [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; (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×
- [(6, 3) code from parity check matrix](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Alinear-block-code-6-3-h-matrix) — Communication Systems, chapter 8
- [Hamming distance and weight; rate 1/3 convolutional encoder](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Ahamming-third-rate-convolutional) — Communication Systems, chapter 8
- [Hamming distance and weight importance; syndrome decoding](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Ahamming-importance-syndrome-decoding) — Communication Systems, chapter 8
