Hamming distance function for bits is an injective or surjective function?

164 Views Asked by At

Let's say we have

d: T8 x T8 -> {0,1,2,3,4,5,6,7,8} $$d(a,b) = \sum_{i=1}^8 ai \oplus bi $$

Where a1 is the bit a that is at position i and bi and the bit b that is in position i.

Would this be an injective or surjective function?

If I understand correctly it is an injective function, but have trouble exactly explaining why.

Thanks.

1

There are 1 best solutions below

2
On

To be injective you would have to have the distance be unique for each pair of bit strings. As there are only $9$ possible distances and many more pairs of bit strings, there must be multiple pairs that have the same distance. It should not be hard to find a specific example.