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 Tue Jan 16 10:34:44 2018.

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