English

Rollercoasters with Plateaus

Data Structures and Algorithms 2024-07-29 v1 Combinatorics

Abstract

In this paper we investigate the problem of detecting, counting, and enumerating (generating) all maximum length plateau-kk-rollercoasters appearing as a subsequence of some given word (sequence, string), while allowing for plateaus. We define a plateau-kk-rollercoaster as a word consisting of an alternating sequence of (weakly) increasing and decreasing \emph{runs}, with each run containing at least kk \emph{distinct} elements, allowing the run to contain multiple copies of the same symbol consecutively. This differs from previous work, where runs within rollercoasters have been defined only as sequences of distinct values. Here, we are concerned with rollercoasters of \emph{maximum} length embedded in a given word ww, that is, the longest rollercoasters that are a subsequence of ww. We present algorithms allowing us to determine the longest plateau-kk-roller\-coasters appearing as a subsequence in any given word ww of length nn over an alphabet of size σ\sigma in O(nσk)O(n \sigma k) time, to count the number of plateau-kk-rollercoasters in ww of maximum length in O(nσk)O(n \sigma k) time, and to output all of them with O(n)O(n) delay after O(nσk)O(n \sigma k) preprocessing. Furthermore, we present an algorithm to determine the longest common plateau-kk-rollercoaster within a set of words in O(Nkσ)O(N k \sigma) where NN is the product of all word lengths within the set.

Keywords

Cite

@article{arxiv.2407.18620,
  title  = {Rollercoasters with Plateaus},
  author = {Duncan Adamson and Pamela Fleischmann and Annika Huch},
  journal= {arXiv preprint arXiv:2407.18620},
  year   = {2024}
}
R2 v1 2026-06-28T17:54:25.369Z