# Hamming-distance working · example 1

Subject: Computer Networks

Exam: TEE

Reader: https://deep-learning-study-room.vercel.app/cn/#tee/read/error-control/distance-1

Canonical: https://deep-learning-study-room.vercel.app/read/cn/tee/read/error-control--distance-1/

TEE · Unit 3 before ALOHA · current syllabus 702AI0C023

### Practice question. For the binary codewords C1=1001101, C2=1110001, C3=1010101, find every pairwise Hamming distance, the minimum distance, and the guaranteed error detection/correction limits. [5 practice marks]

#### Answer

## Given

| Codeword | Bits |
| --- | --- |
| C1 | 1001101 |
| C2 | 1110001 |
| C3 | 1010101 |

## To find

All pair distances, dmin and the maximum guaranteed numbers of errors.

## Formula and why



$$
d(a,b)=\mathrm{weight}(a\oplus b)
$$





$$
s=d_{\min}-1,\quad t=\lfloor(d_{\min}-1)/2\rfloor
$$



XOR exposes differing positions. Use the closest codeword pair, because it is the weakest separation in the code.

## Step-by-step solution

#### Step 1. XOR every distinct pair

| Pair | First | Second | XOR | Distance |
| --- | --- | --- | --- | --- |
| C1 vs C2 | 1001101 | 1110001 | 0111100 | 4 |
| C1 vs C3 | 1001101 | 1010101 | 0011000 | 2 |
| C2 vs C3 | 1110001 | 1010101 | 0100100 | 2 |

#### Step 2. Take the minimum

dmin = min(4, 2, 2) = 2.

#### Step 3. Calculate the guarantees

Detect = 2−1 = 1; correct = floor((2−1)/2) = 0.

#### Step 4. Justify geometrically

2 bit changes can reach another valid codeword, so only 1 are guaranteed detectable. Correction regions require 2t < 2.

**Final answer:** dmin=2; detect up to 1 errors; correct up to 0 errors.

#### What this result means

A distance of one particular pair does not set the whole-code capability unless it is the minimum.
