English

Bounded Weighted Edit Distance: Dynamic Algorithms and Matching Lower Bounds

Data Structures and Algorithms 2025-07-04 v1

Abstract

The edit distance ed(X,Y)ed(X,Y) of two strings X,YΣX,Y\in \Sigma^* is the minimum number of character edits (insertions, deletions, and substitutions) needed to transform XX into YY. Its weighted counterpart edw(X,Y)ed^w(X,Y) minimizes the total cost of edits, which are specified using a function ww, normalized so that each edit costs at least one. The textbook dynamic-programming procedure, given strings X,YΣnX,Y\in \Sigma^{\le n} and oracle access to ww, computes edw(X,Y)ed^w(X,Y) in O(n2)O(n^2) time. Nevertheless, one can achieve better running times if the computed distance, denoted kk, is small: O(n+k2)O(n+k^2) for unit weights [Landau and Vishkin; JCSS'88] and O~(n+nk3)\tilde{O}(n+\sqrt{nk^3}) for arbitrary weights [Cassis, Kociumaka, Wellnitz; FOCS'23]. In this paper, we study the dynamic version of the weighted edit distance problem, where the goal is to maintain edw(X,Y)ed^w(X,Y) for strings X,YΣnX,Y\in \Sigma^{\le n} that change over time, with each update specified as an edit in XX or YY. Very recently, Gorbachev and Kociumaka [STOC'25] showed that the unweighted distance ed(X,Y)ed(X,Y) can be maintained in O~(k)\tilde{O}(k) time per update after O~(n+k2)\tilde{O}(n+k^2)-time preprocessing; here, kk denotes the current value of ed(X,Y)ed(X,Y). Their algorithm generalizes to small integer weights, but the underlying approach is incompatible with large weights. Our main result is a dynamic algorithm that maintains edw(X,Y)ed^w(X,Y) in O~(k3γ)\tilde{O}(k^{3-\gamma}) time per update after O~(nkγ)\tilde{O}(nk^\gamma)-time preprocessing. Here, γ[0,1]\gamma\in [0,1] is a real trade-off parameter and k1k\ge 1 is an integer threshold fixed at preprocessing time, with \infty returned whenever edw(X,Y)>ked^w(X,Y)>k. We complement our algorithm with conditional lower bounds showing fine-grained optimality of our trade-off for γ[0.5,1)\gamma \in [0.5,1) and justifying our choice to fix kk.

Keywords

Cite

@article{arxiv.2507.02548,
  title  = {Bounded Weighted Edit Distance: Dynamic Algorithms and Matching Lower Bounds},
  author = {Itai Boneh and Egor Gorbachev and Tomasz Kociumaka},
  journal= {arXiv preprint arXiv:2507.02548},
  year   = {2025}
}

Comments

ESA 2025

R2 v1 2026-07-01T03:44:47.664Z