Question

A question asks: find the hamming distance of the following code:

11111  
10101  
01010  
11100  
00011  
11001

The answer is 2. How does this work? I thought hamming distance is only between two strings?

Was it helpful?

Solution

The Hamming distance of a code is defined as the minimum distance between any 2 codewords. So, in your case, finding the Hamming distance between any 2 of the listed codewords, no one is less than 2.

OTHER TIPS

Here is some Python-code to find it automatically:

code = [
(0,0,0,0,0,0),
(0,0,1,0,0,1),
(0,1,0,0,1,0),
(0,1,1,0,1,1),
(1,0,0,1,0,0),
(1,0,1,1,0,1),
(1,1,0,1,1,0),
(1,1,1,1,1,1)]

def hammingDistance(a, b):
    distance = 0
    for i in xrange(len(a)):
        distance += a[i]^b[i]
    return distance

def minHammingDistance(code):
    minHammingDistance = len(code[0])
    for a in code:
        for b in code:
            if a != b:
                tmp = hammingDistance(a, b)
                if tmp < minHammingDistance:
                    minHammingDistance = tmp
    return minHammingDistance

print("min Hamming distance: %i" % minHammingDistance(code))

We have a theorem that d_min=weight(sum(all codes)); weight is the number of non zeros in the result string . In your example modulo add all string codes like first column of all and second....... then we get code as [ 0 0 1 1 0 ], weight of this is 2 ( no. of non zeros), i.e the minimum distance of hamming code

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top