Bounded Edit Distance: Optimal Static and Dynamic Algorithms for Small Integer Weights
Egor Gorbachev, Tomasz Kociumaka
Abstract
The edit distance (also known as the Levenshtein distance) of two strings is the minimum number of character insertions, deletions, and substitutions needed to transform one string into the other. The textbook algorithm determines the edit distance of two length-n strings in O(n2) time, and one of the foundational results of fine-grained complexity is that any polynomial-factor improvement upon this quadratic runtime would violate the Orthogonal Vectors Hypothesis. In the bounded version of the problem, where the complexity is parameterized by the value k of the edit distance, the classic algorithm of Landau and Vishkin [JCSS’88] achieves O(n+k2) time, which is optimal (up to sub-polynomial factors and conditioned on OVH) as a function of n and k. While the Levenshtein distance is a fundamental theoretical notion, most practical applications use weighted edit distance, where the weight (cost) of each edit can be an arbitrary real number in [1,∞) that may depend on the edit type and the characters involved. Unfortunately, the Landau–Vishkin algorithm does not generalize to the weighted setting and, for many decades, a simple O(nk)-time dynamic programming procedure remained the state of the art for bounded weighted edit distance. Only recently, Das, Gilbert, Hajiaghayi, Kociumaka, and Saha [STOC’23] provided an O(n+k5)-time algorithm; shortly afterward, Cassis, Kociumaka, and Wellnitz [FOCS’23] presented an Õ(n+√nk3)-time solution (where Õ(·) hides polylogn factors) and proved this runtime optimal for √n ≤ k ≤ n (up to sub-polynomial factors and conditioned on the All-Pairs Shortest Paths Hypothesis). Notably, the hard instances constructed to establish the underlying conditional lower bound use fractional weights with large denominators, reaching (n), which stands in contrast to weight functions used in practice (e.g., in bioinformatics) that, after normalization, typically attain small integer values. Our first main contribution is a surprising discovery that the Õ(n+k2) running time of the Landau–Vishkin algorithm can be recovered if the weights are small integers (e.g., if some specific weight function is fixed in a given application). In general, our solution takes Õ(n+minW,√k· k2) time for integer weights not exceeding a threshold W. Despite matching time complexities, we do not use the Landau–Vishkin framework; instead, we build upon the recent techniques for arbitrary weights. For this, we exploit extra structure following from integer weights and avoid further bottlenecks using several novel ideas to give faster and more robust implementations of multiple steps of the previous approach. Next, we shift focus to the dynamic version of the unweighted edit distance problem, which asks to maintain the edit distance of two strings that change dynamically, with each update modeled as a single edit (character insertion, deletion, or substitution). For many years, the best approach for dynamic edit distance combined the Landau–Vishkin algorithm with a dynamic strings implementation supporting efficient substring equality queries, such as one by Mehlhorn, Sundar, and Uhrig [SODA’94]; the resulting solution supports updates in Õ(k2) time. Recently, Charalampopoulos, Kociumaka, and Mozes [CPM’20] observed that a framework of Tiskin [SODA’10] yields a dynamic algorithm with an update time of Õ(n). This is optimal in terms of n: significantly faster updates would improve upon the static O(n2)-time algorithm and violate OVH. With the state-of-the-art update time at Õ(minn,k2), an exciting open question is whether Õ(k) update time is possible. Our second main contribution is an affirmative answer to this question: we present a deterministic dynamic algorithm that maintains the edit distance in Õ(k) worst-case time per update. Surprisingly, this result builds upon our new static solution and hence natively supports small integer weights: if they do not exceed a threshold W, the update time becomes Õ(W2 k).
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 1d2923fe-4bb6-44c7-8ae6-59815c47dcddCited by top-tier papers5
- Faster Weighted and Unweighted Tree Edit Distance and APSP EquivalenceJakob Nogler, Adam Polak, Barna Saha, Virginia Vassilevska Williams et al.STOC 2025 · 4 citations
- Approximation Schemes for Edit Distance and LCS in Quasi-Strongly Subquadratic TimeXiao Mao, Aviad RubinsteinSTOC 2026 · 4 citations
- Pattern Matching under Weighted Edit DistancePanagiotis Charalampopoulos, Tomasz Kociumaka, Philip WellnitzFOCS 2025 · 3 citations
- Dynamic Dyck and Tree Edit Distance: Decompositions and Reductions to String Edit DistanceDebarati Das, Jacob Gilbert, MohammadTaghi Hajiaghayi, Tomasz Kociumaka et al.FOCS 2025 · 1 citation
- The Complexity of Dynamic LZ77 is ?Θ(n2/3)Itai Boneh, Shay Golan, Matan KrausSODA 2026
Builds on20
- Does preprocessing help in fast sequence comparisons?Elazar Goldenberg, Aviad Rubinstein, Barna SahaSTOC 2020 · 15 citations
- Dynamic algorithms for LIS and distance to monotonicityMichael Mitzenmacher, Saeed SeddighinSTOC 2020 · 11 citations
- Sublinear-Time Algorithms for Computing & Embedding Gap Edit DistanceTomasz Kociumaka, Barna SahaFOCS 2020 · 9 citations
- Faster Pattern Matching under Edit Distance : A Reduction to Dynamic Puzzle Matching and the Seaweed Monoid of Permutation MatricesPanagiotis Charalampopoulos, Tomasz Kociumaka, Philip WellnitzFOCS 2022 · 8 citations
- Near-Optimal Quantum Algorithms for Bounded Edit Distance and Lempel-Ziv FactorizationDaniel Gibney, Ce Jin, Tomasz Kociumaka, Sharma V. ThankachanSODA 2024 · 7 citations
Related papers
- Optimal Algorithms for Bounded Weighted Edit DistanceAlejandro Cassis, Tomasz Kociumaka, Philip WellnitzFOCS 2023 · 4 citations
- Weighted Edit Distance Computation: Strings, Trees, and DyckDebarati Das, Jacob Gilbert, MohammadTaghi Hajiaghayi, Tomasz Kociumaka et al.STOC 2023 · 4 citations
- Approximating Edit Distance in the Fully Dynamic ModelTomasz Kociumaka, Anish Mukherjee, Barna SahaFOCS 2023 · 1 citation
- Almost-optimal sublinear-time edit distance in the low distance regimeKarl Bringmann, Alejandro Cassis, Nick Fischer, Vasileios NakosSTOC 2022 · 4 citations
- Faster Sublinear-Time Edit DistanceKarl Bringmann, Alejandro Cassis, Nick Fischer, Tomasz KociumakaSODA 2024 · 3 citations
