arXiv:2610.01311cs.DSOct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.01311

Factor Three Approximation for Edit Distance

Egor Gorbachev

Abstract

We give randomized algorithms for 3-approximate edit distance in O~(N11/6)\tilde{\mathcal{O}}(N^{11/6}) time for unweighted edit distance and in O~(N40/21)\tilde{\mathcal{O}}(N^{40/21}) time for arbitrary metric edit weights, where NN is the total input length.1^1

For non-metric costs, we prove an unconditional Ω(N2)\Omega(N^2) oracle-query lower bound for every approximation factor depending only on NN, even for symmetric weights or weights satisfying the triangle inequality (but not both). Under the Orthogonal Vectors Hypothesis, we show a similar result for constant-size alphabets. This holds even for symmetric weights over a size-3 alphabet or triangle-inequality weights over a size-2 alphabet. In contrast, for symmetric weights over a binary alphabet we show an O~(N40/21)\tilde{\mathcal{O}}(N^{40/21})-time 3-approximation algorithm.

1 Introduction

The edit distance ed(X,Y)\text{ed}(X, Y) of two strings XX and YY is the smallest number of character insertions, deletions, and substitutions needed to transform one string into the other. For X∈ΣmX \in \Sigma^m and Y∈ΣnY \in \Sigma^n over a finite alphabet Σ\Sigma, we write N:=max⁡{2,m+n}N := \max\{2, m + n\} and call XX the source string and YY the target string. The classical dynamic program of Wagner and Fischer [WF74] computes ed(X,Y)\text{ed}(X, Y) in O(N2)\mathcal{O}(N^2) time by comparing all pairs of prefixes. Subsequent work obtained faster algorithms when the distance k:=ed(X,Y)k := \text{ed}(X, Y) is small: Ukkonen [Ukk85] achieved time complexity O(Nk)\mathcal{O}(Nk), while Landau and Vishkin [LV88] gave an algorithm running in O(N+k2)\mathcal{O}(N + k^2) time.

Logarithmic improvements over the quadratic bound were also known, starting with Masek and Paterson [MP80] for fixed alphabets. Nevertheless, no truly subquadratic exact algorithm, with running time O(N2−δ)\mathcal{O}(N^{2-\delta}) for an absolute constant δ>0\delta > 0, is known for general inputs. In 2015, Backurs and Indyk [BI15] gave a fine-grained explanation for the lack of progress: such an algorithm would refute the Orthogonal Vectors Hypothesis (OVH) and thus also the Strong Exponential Time Hypothesis (SETH).

As improvement for the exact computation is out of reach at the moment, it is natural to turn to developing approximation algorithms. For example, Andoni, Krauthgamer, and Onak [AKO10] obtained a (log⁡N)O(1/ε)(\log N)^{\mathcal{O}(1/\varepsilon)}-approximation in O(N1+ε)\mathcal{O}(N^{1+\varepsilon}) time for each fixed ε>0\varepsilon > 0. The first constant-factor approximation in truly subquadratic time was given by Chakraborty, Das, Goldenberg, Koucký, and Saks in 2018 [CDG+^{+}18]: their original analysis achieved factor 1680 in O~(N12/7)\tilde{\mathcal{O}}(N^{12/7}) time. Later in 2018, Andoni [And18] improved the factor to 3+ε3 + \varepsilon in Oε(N1.693)\mathcal{O}_{\varepsilon}(N^{1.693}) time. Goldenberg, Rubinstein, and Saha [GRS20], in their 2020 work, obtained a (3+ε)(3 + \varepsilon)-approximation in N1.6+o(1)N^{1.6+o(1)} time. In 2020, Andoni [And20] gave a simpler truly subquadratic (3+ε)(3 + \varepsilon)-approximation algorithm.

Other results explore different parts of the tradeoff. Andoni and Nosatzki [AN20] showed that, for every fixed δ>0\delta > 0, an Oδ(1)\mathcal{O}_{\delta}(1)-factor approximation is possible in O(N1+δ)\mathcal{O}(N^{1+\delta}) time. More recently, Fox, Mader, Quanrud, Tavasoli, and Wang [FMQ+^{+}26] obtained a (3+ε)(3+\varepsilon)-approximation in O~ε(N6/5k2/5)\tilde{\mathcal{O}}_{\varepsilon}(N^{6/5}k^{2/5}) time where kk is the edit distance ed(X,Y)\text{ed}(X,Y), improving the time complexity for sublinear distances. Mao and Rubinstein [MR26] obtained a (1+ε)(1+\varepsilon)-approximation in N2/2log⁡Ω(1)NN^{2}/2^{\log \Omega(1)} N time for every fixed ε>0\varepsilon > 0. This is a substantial saving, but it is still N2−o(1)N^{2-o(1)}, rather than truly subquadratic. Thus, despite much progress in running time, the general-input multiplicative guarantees in truly subquadratic time stayed slightly above 3 for nearly eight years. We achieve factor three exactly, with no additive error.

1^{1} O~\tilde{\mathcal{O}} hides factors polynomial in log⁡N\log N.

Factor Three Approximation for Edit Distance

Sketch of the (3+ε)(3+\varepsilon)-approximation algorithms. The algorithms behind the 3+ε3+\varepsilon bounds partition the source string XX into consecutive substrings UiU_i, called source blocks, of length at most W=o(N)W = o(N) each. The optimal (unknown) alignment induces a partition of YY into target substrings ViV_i such that the global alignment of XX onto YY can be viewed as a concatenation of optimal alignments of UiU_i onto ViV_i. It remains to approximately compare each UiU_i with all substrings of YY and pick the appropriate ViV_i. Computing all these comparisons directly would be too expensive. Instead, we use the following routing idea: We consider a small set C\mathcal{C} of intermediate strings we call centers and compute distances from strings in C\mathcal{C} to all source blocks UiU_i and all substrings of YY. For each UiU_i, we pick a center CiC_i minimizing ri:=ed(Ui,Ci)r_i := \text{ed}(U_i, C_i). Then, whenever we need to approximate the distance ed(Ui,Y[p…q])\text{ed}(U_i, Y[p \ldots q]) from a source block UiU_i to some substring Y[p…q)Y[p \ldots q) we use triangle inequality of edit distance to claim that

ed(Ui,Y[p…q))≤ri+ed(Ci,Y[p…q))≤ed(Ui,Y[p…q])+2ri.\mathsf{e d}(U_{i},Y[p\ldots q))\leq r_{i}+\mathsf{e d}(C_{i},Y[p\ldots q))\leq\mathsf{e d}(U_{i},Y[p\ldots q])+2r_{i}.

Therefore, if ed(Ui,Y[p…q])≥ri\text{ed}(U_i, Y[p \ldots q]) \geq r_i, this routing leads to a 3-approximation of ed(Ui,Y[p…q])\text{ed}(U_i, Y[p \ldots q]). A separate sample-based search supplies exact comparisons for many of the inexpensive alignments with ed(Ui,Vi)<ri\text{ed}(U_i, V_i) < r_i. The search need not find every such comparison: it suffices to bound the total cost of those it misses. This is where an excess above the factor three comes from.

How correcting a center saves the ε\varepsilon error. To achieve 3-approximation, we counteract the o(1)o(1) excess of sample-based search by marginally improving the triangle-inequality-based loss. We move each selected center CiC_i slightly closer to its source block UiU_i. Setting Ci:=UiC_i := U_i would remove the routing overhead entirely, but would also destroy the benefit of sharing preprocessing. It turns out that it is enough to undo one edit in an optimal alignment of UiU_i onto CiC_i. We choose the centers in such a way that ri≤∣Ui∣≤Wr_i \leq |U_i| \leq W holds. The overhead can now be bounded by 2(ri−1)≤(2−2/W)ri2(r_i - 1) \leq (2 - 2/W)r_i instead of 2ri2r_i. We choose the remaining approximation errors small enough for this Θ(1/W)\Theta(1/W) saving to cover them.

The single corrected edit in the center CiC_i is different for each source block UiU_i, but it does not require separate preprocessing against the entire target string YY. We use implicit DIST matrices [Sch98] to efficiently overcome this complication.

We are now ready to formulate our unit-cost approximation algorithm. We say that an event holds with high probability if, for any prescribed constant c>0c > 0, its probability is at least 1−N−c1 - N^{-c} after choosing the algorithm's constants appropriately.

Theorem 1.1 (Unit costs). There is a randomized algorithm that on every pair of input strings X∈ΣmX \in \Sigma^m and Y∈ΣnY \in \Sigma^n runs in O~((n+m)11/6)\tilde{\mathcal{O}}((n + m)^{11/6}) time and returns an alignment A\mathcal{A} of XX onto YY of unweighted cost D^\widehat{D} such that D^≤3ed(X,Y)\widehat{D} \leq 3\text{ed}(X, Y) holds with high probability.

References (24)