English

Approximate counting of permutation patterns

Data Structures and Algorithms 2025-10-27 v3

Abstract

We consider the problem of counting the copies of a length-kk pattern σ\sigma in a sequence f ⁣:[n]Rf \colon [n] \to \mathbb{R}, where a copy is a subset of indices i1<<ik[n]i_1 < \ldots < i_k \in [n] such that f(ij)<f(i)f(i_j) < f(i_\ell) if and only if σ(j)<σ()\sigma(j) < \sigma(\ell). This problem is motivated by a range of connections and applications in ranking, nonparametric statistics, combinatorics, and fine-grained complexity, especially when kk is a small fixed constant. Recent advances have significantly improved our understanding of counting and detecting patterns. Guillemot and Marx [2014] obtained an O(n)O(n) time algorithm for the detection variant for any fixed kk. Their proof has laid the foundations for the discovery of the twin-width, a concept that has notably advanced parameterized complexity in recent years. Counting, in contrast, is harder: it has a conditional lower bound of nΩ(k/logk)n^{\Omega(k / \log k)} [Berendsohn, Kozma, and Marx, 2019] and is expected to be polynomially harder than detection as early as k=4k = 4, given its equivalence to counting 44-cycles in graphs [Dudek and Gawrychowski, 2020]. In this work, we design a deterministic near-linear time (1+ε)(1+\varepsilon)-approximation algorithm for counting σ\sigma-copies in ff for all k5k \leq 5. Combined with the conditional lower bound for k=4k=4, this establishes the first known separation between approximate and exact pattern counting. Interestingly, while neither the sequence ff nor the pattern σ\sigma are monotone, our algorithm makes extensive use of coresets for monotone functions [Har-Peled, 2006]. Along the way, we develop a near-optimal data structure for (1+ε)(1+\varepsilon)-approximate increasing pair range queries in the plane, which exhibits a conditional separation from the exact case and may be of independent interest.

Keywords

Cite

@article{arxiv.2411.04718,
  title  = {Approximate counting of permutation patterns},
  author = {Omri Ben-Eliezer and Slobodan Mitrović and Pranjal Srivastava},
  journal= {arXiv preprint arXiv:2411.04718},
  year   = {2025}
}

Comments

To appear in SODA 2026. We thank the reviewers for pointing out the connection to coresets for monotone functions [Har-Peled '06]

R2 v1 2026-06-28T19:51:33.525Z