🤖 AI Summary
This paper studies the efficient maintenance of weighted edit distance in dynamic string settings: given two strings (X) and (Y) undergoing frequent insertions, deletions, or substitutions over time, how to update their weighted edit distance (ed^w(X,Y)) rapidly. We propose the first dynamic algorithm supporting arbitrary positive weights, featuring three key innovations: (i) a prespecified distance threshold, (ii) dynamic programming pruning, and (iii) an oracle-based weight query mechanism. The preprocessing time is ( ilde{O}(nk^gamma)), and each update takes ( ilde{O}(k^{3-gamma})) time for (gamma in [0.5,1)), where (k = ed^w(X,Y)) denotes the current distance—achieving sublinear update complexity. Furthermore, under plausible fine-grained complexity assumptions, we establish matching upper and lower bounds, proving the algorithm’s optimality in the fine-grained sense.
📝 Abstract
The edit distance $ed(X,Y)$ of two strings $X,Yin Σ^*$ is the minimum number of character edits (insertions, deletions, and substitutions) needed to transform $X$ into $Y$. Its weighted counterpart $ed^w(X,Y)$ minimizes the total cost of edits, which are specified using a function $w$, normalized so that each edit costs at least one. The textbook dynamic-programming procedure, given strings $X,Yin Σ^{le n}$ and oracle access to $w$, computes $ed^w(X,Y)$ in $O(n^2)$ time. Nevertheless, one can achieve better running times if the computed distance, denoted $k$, is small: $O(n+k^2)$ for unit weights [Landau and Vishkin; JCSS'88] and $ ilde{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 $ed^w(X,Y)$ for strings $X,Yin Σ^{le n}$ that change over time, with each update specified as an edit in $X$ or $Y$. Very recently, Gorbachev and Kociumaka [STOC'25] showed that the unweighted distance $ed(X,Y)$ can be maintained in $ ilde{O}(k)$ time per update after $ ilde{O}(n+k^2)$-time preprocessing; here, $k$ denotes the current value of $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 $ed^w(X,Y)$ in $ ilde{O}(k^{3-γ})$ time per update after $ ilde{O}(nk^γ)$-time preprocessing. Here, $γin [0,1]$ is a real trade-off parameter and $kge 1$ is an integer threshold fixed at preprocessing time, with $infty$ returned whenever $ed^w(X,Y)>k$. We complement our algorithm with conditional lower bounds showing fine-grained optimality of our trade-off for $γin [0.5,1)$ and justifying our choice to fix $k$.