Definition

Hamming distance is a metric that measures the difference between two strings of equal lengths by counting the number of positions whose respective symbols differ. In code error detection and correction, it determines the bit flips necessary to convert one binary code word to another. 

Hamming Distance Examples 

For instance, the Hamming distance between the binary sequences “10101010” and “11001100” is 4 since there are four positions where the bits don’t match. 

Difference Between Hamming Distance and Other Metrics 

The Hamming distance is often mistaken for other string similarity measures, such as the Levenshtein distance, which measures the least number of single-character edits needed to change one string into another.

Pros and Cons of the Hamming Distance

Pros

Cons