Hamming distance


Definition: The number of bits which differ between two binary strings. More formally, the distance between two strings A and B is ∑ | Ai - Bi |.

Aggregate parent (I am a part of or used in ...)
brute force string search with mismatches.

See also Levenshtein distance, Manhattan distance.

Note: After Ralf Rabaetje <> 4 February 2000.

The Hamming distance can be interpreted as the number of bits which need to be changed (corrupted) to turn one string into the other. Sometimes the number of characters is used instead of the number of bits. Hamming distance can be seen as Manhattan distance between bit vectors.

Author: PEB

Go to the Dictionary of Algorithms and Data Structures home page.

If you have suggestions, corrections, or comments, please get in touch with Paul Black.

Entry modified 31 May 2006.
HTML page formatted Wed Mar 13 12:42:46 2019.

Cite this as:
Paul E. Black, "Hamming distance", in Dictionary of Algorithms and Data Structures [online], Paul E. Black, ed. 31 May 2006. (accessed TODAY) Available from: