Overview
Levenshtein Distance uses dynamic programming to compare prefixes of two strings and choose the cheapest edit sequence.
Measures how many insertions, deletions, or substitutions transform one string into another.
Compact metadata for implementation and discovery.
Levenshtein Distance uses dynamic programming to compare prefixes of two strings and choose the cheapest edit sequence.
Quick facts
Runtime and memory behavior at a glance.
Best
O(nm)
Average
O(nm)
Worst
O(nm)
Space
O(nm)
dp[i][j] = min(dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1] + cost)Chooses the cheapest insert, delete, or substitute action.
Show a dynamic programming grid filling with edit costs.
Space can be reduced when only the distance is needed.
What each reference supports for this entry.
String algorithms reference covering Levenshtein Distance recurrences, automata/indexing structures, or exact/approximate matching role.
Original reference for edit distance with insertions, deletions, substitutions, and reversals in string correction.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Pattern Matching · Extended
Jaro-Winkler and Levenshtein distance are string similarity measures with different error models.
Compare with thisPattern Matching · Extended
Optimal string alignment extends Levenshtein-style edit distance with adjacent transpositions under a restricted model.
Compare with thisPattern Matching · Core
Levenshtein distance allows insertions and deletions, while Hamming distance assumes equal length.
Compare with thisPattern Matching · Core
Both use dynamic programming to align sequences.
Compare with thisBoth use dynamic programming to align sequences.
Levenshtein distance allows insertions and deletions, while Hamming distance assumes equal length.