---
title: "Hamming weight and distance; (7,4) cyclic code for 1011"
subject: "Communication Systems"
chapter: 8
key: "semester_6/communication_systems:hamming-weight-cyclic-1011"
source: https://www.bctengineer.com/q/semester_6/communication_systems/hamming-weight-cyclic-1011
site: BCT Engineering
---

# Hamming weight and distance; (7,4) cyclic code for 1011

Communication Systems · Chapter 8: Error Detection and Correction Coding

- Asked in: 2076 Asoj (CS II), 4+5 marks; 2074 Asoj (CS II), 2+6 marks (asked 2 times)
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/communication_systems/hamming-weight-cyclic-1011
- Whole chapter: https://www.bctengineer.com/md/semester_6/communication_systems/chapter-8

## Question

Define Hamming Weight and Hamming Distance. Construct a (7, 4) cyclic code using a generator polynomial g(x) = x³ + x² + 1 with data vector 1011.

## Short answer

Hamming weight is the number of 1s in a vector; Hamming distance is the number of differing positions between two vectors. For data 1011, non-systematic codeword is 1111111; systematic codeword is 1011100 (parity 100).

## Answer

#### Hamming weight

The **Hamming weight** $w(\mathbf{c})$ of a code vector is the number of non-zero (1) elements in it.

Example: $w(1011100)=4$, $w(0000000)=0$.

#### Hamming distance

The **Hamming distance** $d(\mathbf{c}_1,\mathbf{c}_2)$ between two code vectors of equal length is the number of positions in which they differ. It equals the weight of their modulo-2 sum: $d(\mathbf{c}_1,\mathbf{c}_2)=w(\mathbf{c}_1\oplus\mathbf{c}_2)$.

Example: $\mathbf{c}_1=1011100$, $\mathbf{c}_2=1111111$; $\mathbf{c}_1\oplus\mathbf{c}_2=0100011$, so $d=3$.

The smallest distance between any two codewords is the **minimum distance** $d_{min}$; for a linear code it equals the smallest non-zero weight. A code detects up to $d_{min}-1$ errors and corrects up to $\lfloor (d_{min}-1)/2\rfloor$. For the (7,4) cyclic Hamming code $d_{min}=3$: it detects 2 and corrects 1 error.

#### (7,4) cyclic code for data 1011

Given $g(x)=x^3+x^2+1$, $n-k=3$. Convention: leftmost bit = highest power, so $d(x)=x^3+x+1$. Modulo-2 arithmetic.

**Non-systematic form:** $c(x)=d(x)g(x)$

$$
\begin{aligned}
c(x)&=(x^3+x+1)(x^3+x^2+1)\\
&=x^6+x^5+x^3\;+\;x^4+x^3+x\;+\;x^3+x^2+1\\
&=x^6+x^5+x^4+x^3+x^2+x+1
\end{aligned}
$$

Non-systematic code vector: **1111111**.

**Systematic form:**

1. $x^3d(x)=x^6+x^4+x^3$
2. Divide by $g(x)$:

```text
              x^3 + x^2
          -------------------------
x^3+x^2+1 ) x^6 +     x^4 + x^3
            x^6 + x^5 +       x^3
            -----------------------
                  x^5 + x^4
                  x^5 + x^4 +       x^2
                  -------------------
                                    x^2
```

3. Remainder $p(x)=x^2$, parity bits $= 100$.
4. $c(x)=x^6+x^4+x^3+x^2$.

Systematic code vector: **1011 100** (message, then parity).

Check: $c(x)=(x^3+x^2)g(x)$, so $c(x)$ is divisible by $g(x)$ and is a valid codeword.

| Form | Code vector | Weight |
|---|---|---|
| Non-systematic | 1111111 | 7 |
| Systematic | 1011100 | 4 |

## Check yourself

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

1. What is the Hamming weight of the code vector 1011100?
   A. 3
   B. 4
   C. 7
   D. 5
   Answer: B. Weight is the number of 1s; 1011100 has four 1s. (Key point: Hamming weight)

2. What is the Hamming distance between 1011100 and 1111111?
   A. 3
   B. 4
   C. 7
   D. 2
   Answer: A. The XOR is 0100011, which has weight 3; distance equals the weight of the modulo-2 sum. (Key point: Hamming distance)

3. A (7,4) cyclic Hamming code has dmin = 3. What can it do?
   A. Detect 3 and correct 1 error
   B. Detect 2 and correct 1 error
   C. Detect 1 and correct 2 errors
   D. Detect 2 and correct 2 errors
   Answer: B. It detects dmin-1 = 2 errors and corrects floor((dmin-1)/2) = 1 error. (Key point: dmin and capability)

4. For data 1011 and g(x) = x^3 + x^2 + 1, what is the systematic code vector and how are the parity bits obtained?
   A. 1011100, from the remainder of x^3 d(x) divided by g(x)
   B. 1111111, from d(x) times g(x)
   C. 1011011, from the quotient of x^3 d(x) divided by g(x)
   D. 0011101, from adding g(x) to d(x)
   Answer: A. x^3 d(x) = x^6 + x^4 + x^3 leaves remainder x^2, so parity 100 follows the message. (Key point: Systematic encoding)

## Related in Communication Systems

- [(7,4) cyclic code with g(x) = x³ + x² + 1 for 1011](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Acyclic-code-7-4-1011-x3x2) — Communication Systems, chapter 8, asked 2×
- [Convolutional vs block codes; (7,4) cyclic code for 1011](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Aconv-vs-block-cyclic-7-4-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
- [(7,4) cyclic code g(x) = 1 + x + x³ for 1011](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Acyclic-7-4-1x-x3-1011) — Communication Systems, chapter 8, asked 2×
- [Hamming weight/distance; validate x = 0111000 with given H](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Ahamming-code-vector-0111000) — Communication Systems, chapter 8, asked 2×

## Related in other subjects

- [Construct a (7,4) Hamming code](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Ahamming-74-construct) — Data Communication, chapter 8
- [Redundancy, Hamming distance, linear vs cyclic](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Aredundancy-hamming-linear-cyclic) — Data Communication, chapter 8
- [Minimum Hamming distance; find k and n](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Amin-hamming-k-n) — 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
