English

A Space-Efficient Algorithm for Longest Common Almost Increasing Subsequence of Two Sequences

Data Structures and Algorithms 2025-05-08 v2

Abstract

Let AA and BB be two number sequences of length nn and mm, respectively, where mnm\le n. Given a positive number δ\delta, a common almost increasing sequence s1sks_1\ldots s_k is a common subsequence for both AA and BB such that for all 2ik2\le i\le k, si+δ>max1j<isjs_i+\delta > \max_{1\le j < i} s_j. The LCaIS problem seeks to find the longest common almost increasing subsequence (LCaIS) of AA and BB. An LCaIS can be computed in O(nm)O(nm\ell) time and O(nm)O(nm) space [Ta, Shieh, Lu (TCS 2021)], where \ell is the length of the LCaIS of AA and BB. In this paper we first give an O(nm)O(nm\ell)-time and O(n+m)O(n+m\ell)-space algorithm to find LCaIS, which improves the space complexity. We then design an O((n+m)logn+MlogM+C)O((n+m)\log n +\mathcal{M}\log \mathcal{M} + \mathcal{C}\ell)-time and O(M(+logM))O(\mathcal{M}(\ell+\log \mathcal{M}))-space algorithm, which is faster when the number of matching pairs M\mathcal{M} and the number of compatible matching pairs C\mathcal{C} are in o(nm/logm)o(nm/\log m).

Keywords

Cite

@article{arxiv.2503.15442,
  title  = {A Space-Efficient Algorithm for Longest Common Almost Increasing Subsequence of Two Sequences},
  author = {Md Tanzeem Rahat and Md. Manzurul Hasan and Debajyoti Mondal},
  journal= {arXiv preprint arXiv:2503.15442},
  year   = {2025}
}
R2 v1 2026-06-28T22:27:12.606Z