English

Optimal Algorithms for Bounded Weighted Edit Distance

Data Structures and Algorithms 2023-10-25 v2

Abstract

The edit distance of two strings is the minimum number of insertions, deletions, and substitutions of characters needed to transform one string into the other. The textbook dynamic-programming algorithm computes the edit distance of two length-nn strings in O(n2)O(n^2) time, which is optimal up to subpolynomial factors under SETH. An established way of circumventing this hardness is to consider the bounded setting, where the running time is parameterized by the edit distance kk. A celebrated algorithm by Landau and Vishkin (JCSS '88) achieves time O(n+k2)O(n + k^2), which is optimal as a function of nn and kk. Most practical applications rely on a more general weighted edit distance, where each edit has a weight depending on its type and the involved characters from the alphabet Σ\Sigma. This is formalized through a weight function w:Σ{ε}×Σ{ε}Rw : \Sigma\cup\{\varepsilon\}\times\Sigma\cup\{\varepsilon\}\to\mathbb{R} normalized so that w(a,a)=0w(a,a)=0 and w(a,b)1w(a,b)\geq 1 for all a,bΣ{ε}a,b \in \Sigma\cup\{\varepsilon\} with aba \neq b; the goal is to find an alignment of the two strings minimizing the total weight of edits. The O(n2)O(n^2)-time algorithm supports this setting seamlessly, but only very recently, Das, Gilbert, Hajiaghayi, Kociumaka, and Saha (STOC '23) gave the first non-trivial algorithm for the bounded version, achieving time O(n+k5)O(n + k^5). While this running time is linear for kn1/5k\le n^{1/5}, it is still very far from the bound O(n+k2)O(n+k^2) achievable in the unweighted setting. In this paper, we essentially close this gap by showing both an improved O~(n+nk3)\tilde O(n+\sqrt{nk^3})-time algorithm and, more surprisingly, a matching lower bound: Conditioned on the All-Pairs Shortest Paths (APSP) hypothesis, our running time is optimal for nkn\sqrt{n}\le k\le n (up to subpolynomial factors). This is the first separation between the complexity of the weighted and unweighted edit distance problems.

Keywords

Cite

@article{arxiv.2305.06659,
  title  = {Optimal Algorithms for Bounded Weighted Edit Distance},
  author = {Alejandro Cassis and Tomasz Kociumaka and Philip Wellnitz},
  journal= {arXiv preprint arXiv:2305.06659},
  year   = {2023}
}

Comments

Shortened abstract for arXiv. Accepted to FOCS'23. Version 2: minor fixes and aesthetic changes

R2 v1 2026-06-28T10:31:49.787Z