arXiv:2610.09233cs.CCOct 2026

Manuscript Offprint

arXiv:2610.09233

Fine-Grained Hardness of Approximating Dynamic Time Warping

Jihan Wang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

We prove conditional lower bounds for approximating dynamic time warping (DTW) over the uniform metric on three symbols. Let N,MN, M be the two string lengths and n,mn, m their respective numbers of runs. Under the Gap Block Disjointness (GBD) hypothesis, for every fixed κ∈(0,1/6)\kappa \in (0, 1/6) and δ∈(0,1)\delta \in (0, 1), no deterministic algorithm NκδN^{\kappa\delta}-approximates DTW on two explicit strings of length NN in O(N2−δ)O(N^{2-\delta}) time. This matches the known tradeoff between approximation and running-time exponents for deterministic algorithms within any fixed factor greater than six in the approximation exponent. For run-length encoded strings, the Orthogonal Vectors Hypothesis (OVH) rules out any constant-factor approximation in O~((nm)1−δ)\tilde{O}((nm)^{1-\delta}) time for every constant δ>0\delta > 0. More generally, for every fixed η∈(0,1)\eta \in (0, 1), it rules out (N+M)1−η(N+M)^{1-\eta}-approximation in the same running time. These bounds extend to every fixed metric with at least three points, including absolute distance on {0,1,2}\{0, 1, 2\}.

Both reductions use long runs to force equal-symbol matches in low-cost alignments. For explicit strings, we combine Boolean gadgets with deterministic gap amplification to obtain a polynomial approximation gap. For run-length encoded strings, an encoding of regular-expression membership gives accepting instances an alignment whose cost does not increase as selected runs grow. Rejecting instances have distance at least the chosen run length, while the number of runs stays fixed.

1 Introduction

Dynamic time warping (DTW) measures string similarity by minimizing the cost of a monotone alignment that may repeat symbols. Let X, Y be nonempty strings of lengths N, M, respectively. A warping path π\pi is a sequence of cells in the N×MN \times M grid. It starts at (1,1)(1,1) and ends at (N,M)(N,M), using steps (1,0)(1,0), (0,1)(0,1), (1,1)(1,1). Under the uniform metric, its cost is the number of visited cells with unequal symbols. The DTW distance is

DTW(X,Y)=min⁡π∑(i,j)∈π1[X[i]≠Y[j]].\mathrm{DTW}(X,Y)=\min_{\pi}\sum_{(i,j)\in\pi}\mathbf{1}[X[i]\neq Y[j]].

The standard dynamic program computes DTW in O(NM)O(NM) time. Under the Strong Exponential Time Hypothesis (SETH) [IP01], no deterministic strongly subquadratic algorithm computes DTW exactly [ABW15, BK15]. Kuszmaul [Kus19] proved this bound even for equal-length strings over a three-symbol uniform metric.

For two strings of length NN over a uniform metric, Kuszmaul [Kus19] gave a deterministic O(Nε)O(N^\varepsilon)-approximation in O~(N2−ε)\widetilde{O}(N^{2-\varepsilon}) time1^1 for every fixed ε∈(0,1)\varepsilon \in (0,1). How much approximation is

1^{1}Throughout, O~\widetilde{O} hides factors polylogarithmic in the total expanded length N+MN + M.

necessary to obtain a polynomial saving over quadratic time in NN? Under the Gap Block Disjointness hypothesis, we show that such a saving requires a polynomial approximation factor for deterministic algorithms, even over three symbols.

A second approximation question arises for run-length encoded (RLE) strings. This representation stores each maximal run of equal symbols by its symbol and length. Let n,mn, m be the respective numbers of runs in X,YX, Y. Exact DTW on run-length encoded strings can be computed in O~(nm)\widetilde{O}(nm) time [BGMW24]. Under SETH, this is optimal up to subpolynomial factors for deterministic algorithms [ABW15, BK15]. Can approximation give a fixed polynomial improvement over this running time? Under the Orthogonal Vectors Hypothesis (OVH), we rule out such an improvement for every constant approximation factor.

References (30)