Image for Hamming distance

Hamming distance

Hamming distance measures how many positions in two strings of equal length differ from each other. Think of it like comparing two sequences of characters or bits (like 0s and 1s). The Hamming distance counts each spot where they don't match. For example, comparing "1011" and "1001," they differ in one position—the second digit—so their Hamming distance is 1. This concept is useful in error detection, coding theory, and data comparison, helping quantify how similar or different two sequences are.