Abstract
Edit distance is a measure of similarity of two strings based on the minimum number of character insertions, deletions, and substitutions required to transform one string into the other. The edit distance can be computed exactly using a dynamic programming algorithm that runs in quadratic time. Andoni, Krauthgamer, and Onak (2010) gave a nearly linear time algorithm that approximates edit distance within an approximation factor $\text{poly}(\log n)$. In this paper, we provide an algorithm with running time $\tilde{O}(n^{2-2/7})$ that approximates the edit distance within a constant factor.
Introduction
The edit distance (or Levenshtein distance) is a cornerstone of computational biology, natural language processing, and data deduplication. For decades, the $O(n^2)$ dynamic programming algorithm has been the standard for exact computation. However, recent theoretical work under the Strong Exponential Time Hypothesis (SETH) suggests that an exact $O(n^{2-\delta})$ algorithm likely does not exist. This has shifted the focus of the theoretical computer science community toward approximation: can we achieve a "good enough" answer in significantly less than quadratic time?
The ED-UB Algorithm
The authors propose a randomized algorithm called ED-UB (Edit Distance Upper Bound), which breaks the quadratic barrier by avoiding an exhaustive search of the $n \times n$ edit distance grid. The algorithm operates in two main phases:
- The Covering Phase: The algorithm identifies a set of "certified boxes"—pairs of substrings $(I, J)$ where the edit distance is known to be small.
- Dense Case Strategy: In regions with many matches, the algorithm uses random sampling and the triangle inequality to "pivot" off one match and certify many others simultaneously.
- Sparse Case (Diagonal Extension) Strategy: If matches are rare, the algorithm identifies high-quality matches and "stretches" them along their diagonals to cover larger areas of the string.
- The Min-Cost Path Phase: Once a sufficient set of certified boxes is found, the algorithm constructs a "shortcut graph." In this graph, nodes represent positions in the strings, and edges represent either single character edits or the "shortcuts" provided by the certified boxes. Finding the shortest path in this graph yields the final approximation.
Key Insights: Dense/Sparse Duality
The core innovation of the algorithm is its ability to handle different "textures" of string similarity. By switching between a dense strategy (certifying many boxes at once) and a sparse strategy (extending specific good matches), the authors ensure that the algorithm finds important matches quickly regardless of the strings' structure.
The algorithm leverages a geometric property of edit distance: if two substrings are similar, their "diagonal extension" (the larger substrings formed by expanding the window at the same rate) is also likely to be relatively similar. This allows the algorithm to jump across large portions of the strings, effectively bypassing the need to check every character interaction.
Results and Complexity
The algorithm achieves a running time of $\tilde{O}(n^{12/7})$, which is approximately $O(n^{1.714})$. This is considered "truly sub-quadratic" because the exponent is strictly less than 2.
While the initial constant factor proven in this work is 1680, the authors demonstrate that the logic holds for a fixed multiple of the true distance. They suggest that by tweaking parameters, this approximation factor can be significantly improved, potentially down to $(3 + \epsilon)$. As a randomized algorithm, it succeeds with high probability (at least $1 - n^{-5}$).
Conclusion and Future Work
This work provides the first truly sub-quadratic classical algorithm to approximate edit distance within a constant factor. While the high constant factor and implementation complexity may limit immediate practical application compared to simple $O(n^2)$ approaches, the techniques introduced here—particularly the diagonal extension and shortcut graph—have laid the groundwork for even faster algorithms, with subsequent research pushing the running time closer to $O(n^{1+\epsilon})$.
Summary updated