Rollercoasters with Plateaus
Duncan Adamson, Pamela Fleischmann, Annika Huch
TL;DR
This work addresses detecting, counting, and enumerating maximum-length plateau-$k$-rollercoasters as subsequences of a word, where plateau runs may contain repeated symbols but must include at least $k$ distinct letters. It develops a DP-based framework using tables $L_w^{k,h,\xi}$, a rollercoaster count table $R_w^k$, and a next-element graph $\mathrm{NEG}(w)$ to efficiently compute the longest plateau-$k$-rollercoaster in $O(n\sigma k)$ time and enumerate all maximum solutions with $O(n)$ delay after $O(n\sigma k)$ preprocessing; it also extends to counting and enumerating all maximums via dedicated structures. The paper further generalizes to the longest common plateau-$k$-rollercoaster across a set of words, achieving $O(Nk\sigma)$ time where $N=\prod_{w\in\mathcal{W}}|w|$, enabling coherent cross-word pattern discovery. These results advance the understanding of plateau-based subsequence patterns and offer practical tools for combinatorial sequence analysis and related applications. All mathematical constructs are expressed using $...$ notation to maintain formal rigor.
Abstract
In this paper we investigate the problem of detecting, counting, and enumerating (generating) all maximum length plateau-$k$-rollercoasters appearing as a subsequence of some given word (sequence, string), while allowing for plateaus. We define a plateau-$k$-rollercoaster as a word consisting of an alternating sequence of (weakly) increasing and decreasing \emph{runs}, with each run containing at least $k$ \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 $w$, that is, the longest rollercoasters that are a subsequence of $w$. We present algorithms allowing us to determine the longest plateau-$k$-roller\-coasters appearing as a subsequence in any given word $w$ of length $n$ over an alphabet of size $σ$ in $O(n σk)$ time, to count the number of plateau-$k$-rollercoasters in $w$ of maximum length in $O(n σk)$ time, and to output all of them with $O(n)$ delay after $O(n σk)$ preprocessing. Furthermore, we present an algorithm to determine the longest common plateau-$k$-rollercoaster within a set of words in $O(N k σ)$ where $N$ is the product of all word lengths within the set.
