English

The Fine-Grained Complexity of Episode Matching

Data Structures and Algorithms 2024-02-15 v2 Computational Complexity

Abstract

Given two strings SS and PP, the Episode Matching problem is to find the shortest substring of SS that contains PP as a subsequence. The best known upper bound for this problem is O~(nm)\tilde O(nm) by Das et al. (1997) , where n,mn,m are the lengths of SS and PP, respectively. Although the problem is well studied and has many applications in data mining, this bound has never been improved. In this paper we show why this is the case by proving that no O((nm)1ϵ)O((nm)^{1-\epsilon}) algorithm (even for binary strings) exists, unless the Strong Exponential Time Hypothesis (SETH) is false. We then consider the indexing version of the problem, where SS is preprocessed into a data structure for answering episode matching queries PP. We show that for any τ\tau, there is a data structure using O(n+(nτ)k)O(n+\left(\frac{n}{\tau}\right)^k) space that answers episode matching queries for any PP of length kk in O(kτloglogn)O(k\cdot \tau \cdot \log \log n ) time. We complement this upper bound with an almost matching lower bound, showing that any data structure that answers episode matching queries for patterns of length kk in time O(nδ)O(n^\delta), must use Ω(nkkδo(1))\Omega(n^{k-k\delta-o(1)}) space, unless the Strong kk-Set Disjointness Conjecture is false. Finally, for the special case of k=2k=2, we present a faster construction of the data structure using fast min-plus multiplication of bounded integer matrices.

Keywords

Cite

@article{arxiv.2108.08613,
  title  = {The Fine-Grained Complexity of Episode Matching},
  author = {Philip Bille and Inge Li Gørtz and Shay Mozes and Teresa Anna Steiner and Oren Weimann},
  journal= {arXiv preprint arXiv:2108.08613},
  year   = {2024}
}

Comments

This is the full version of a paper accepted to CPM 2022

R2 v1 2026-06-24T05:14:55.912Z