**Hamming Distance**** Problem:** In general, it is assumed that it is more likely to have fewer errors than more errors. This “**worst-case**” approach to coding is intuitively appealing within itself. Nevertheless, it is closely connected to a simple probabilistic model where errors are introduced into the message independently for each symbol and with a fixed probability **p < 1/2**. In order to talk about the “**number of errors**” **hamming distance** is introduced.

** Definition:** The Hamming distance between two integers is the number of positions at which the corresponding bits are different. It is not dependent on the actual values of

**xi**and

**yi**but only if they are equal to each other or not equal.

** Proposition:** The function d is a metric. That is, for every x, y, z ∈ A

_{N}:

- 0 ≤ d(x, y) ≤ N
- d(x, y) = 0 if and only if x = y
- d(x, y) = d(y, x)
- d(x, z) ≤ d(x, y) + d(y, z) (triangle inequality)

__ Rule for Decoding__: Below are the rules:

- Let
**C**be a code of length**N**over an alphabet**A**. - The nearest neighbor decoding rule states that every
**x ∈ A**is decoded to_{N}**cx ∈ C**that is closest to**x**. - That is,
**D(x) = cx**where**cx**is such that**d(x, cx) = minc ∈ C{d(x, c)}**. - If there exists more than one
**c**at this minimal distance, then**D**returns**⊥**. - Code distance and error detection and correction.
- Intuitively, a code is better if all the codewords are far apart.

Formalized Notion:

Let C be a code. The distance of the code, denoted d(C), is defined by:

d(C) = min{d(c1, c2) | c1, c2 ∈ C, c1 6= c2}An

(N, M)-code of distance d is called an(N, M, d)-code. The values N, M, d are called the parameters of the code.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.