English

The Complexity of the Co-Occurrence Problem

Data Structures and Algorithms 2022-11-11 v2

Abstract

Let SS be a string of length nn over an alphabet Σ\Sigma and let QQ be a subset of Σ\Sigma of size q2q \geq 2. The 'co-occurrence problem' is to construct a compact data structure that supports the following query: given an integer ww return the number of length-ww substrings of SS that contain each character of QQ at least once. This is a natural string problem with applications to, e.g., data mining, natural language processing, and DNA analysis. The state of the art is an O(nq)O(\sqrt{nq}) space data structure that -- with some minor additions -- supports queries in O(loglogn)O(\log\log n) time [CPM 2021]. Our contributions are as follows. Firstly, we analyze the problem in terms of a new, natural parameter dd, giving a simple data structure that uses O(d)O(d) space and supports queries in O(loglogn)O(\log\log n) time. The preprocessing algorithm does a single pass over SS, runs in expected O(n)O(n) time, and uses O(d)O(d) space in addition to the input. Furthermore, we show that O(d)O(d) space is optimal and that O(loglogn)O(\log\log n)-time queries are optimal given optimal space. Secondly, we bound d=O(nq)d = O(\sqrt{nq}), giving clean bounds in terms of nn and qq that match the state of the art. Furthermore, we prove that Ω(nq)\Omega(\sqrt{nq}) bits of space is necessary in the worst case, meaning that the O(nq)O(\sqrt{nq}) upper bound is tight to within polylogarithmic factors. All of our results are based on simple and intuitive combinatorial ideas that simplify the state of the art.

Keywords

Cite

@article{arxiv.2206.10383,
  title  = {The Complexity of the Co-Occurrence Problem},
  author = {Philip Bille and Inge Li Gørtz and Tord Stordalen},
  journal= {arXiv preprint arXiv:2206.10383},
  year   = {2022}
}
R2 v1 2026-06-24T11:58:32.402Z