🤖 AI Summary
This paper studies the Longest Common Almost-Increasing Subsequence (LCaIS) problem for two numerical sequences: given sequences A and B and a threshold δ, find the longest common subsequence S such that (s_i + delta > max{s_1, dots, s_{i-1}}) for all (i > 1). We propose the first space-efficient algorithm: a basic version runs in (O(nmell)) time and (O(n + mell)) space; an optimized variant achieves (O((n+m)log n + mathcal{M} log mathcal{M} + mathcal{C}ell)) time and (O(mathcal{M}(ell + log mathcal{M}))) space, where (mathcal{M}) is the number of matching pairs, (mathcal{C}) the number of compatible pairs, and (ell) the optimal solution length. Our key innovations integrate dynamic programming with matching-pair enumeration, compatibility-based pruning, and balanced-tree–augmented binary search—dramatically reducing time and space overhead on sparse inputs. Notably, we reduce the space complexity from the conventional (O(nm)) to near-linear, marking the first such improvement for LCaIS.
📝 Abstract
Let $A$ and $B$ be two number sequences of length $n$ and $m$, respectively, where $mle n$. Given a positive number $delta$, a common almost increasing sequence $s_1ldots s_k$ is a common subsequence for both $A$ and $B$ such that for all $2le ile k$, $s_i+delta>max_{1le j<i} s_j$. The LCaIS problem seeks to find the longest common almost increasing subsequence (LCaIS) of $A$ and $B$. An LCaIS can be computed in $O(nmell)$ time and $O(nm)$ space [Ta, Shieh, Lu (TCS 2021)], where $ell$ is the length of the LCaIS of $A$ and $B$. In this paper we first give an $O(nmell)$-time and $O(n+mell)$-space algorithm to find LCaIS, which improves the space complexity. We then design an $O((n+m)log n +mathcal{M}log mathcal{M} + mathcal{C}ell)$-time and $O(mathcal{M}(ell+log mathcal{M}))$-space algorithm, which is faster when the number of matching pairs $mathcal{M}$ and the number of compatible matching pairs $mathcal{C}$ are in $o(nm/log m)$.