Park et al. [TCS 2020] observed that the similarity between two (numerical) strings can be captured by the Cartesian trees: The Cartesian tree of a string is a binary tree recursively constructed by picking up the smallest value of the string as the root of the tree. Two strings of equal length are said to Cartesian-tree match if their Cartesian trees are isomorphic. Park et al. [TCS 2020] introduced the following Cartesian tree substring matching (CTMStr) problem: Given a text string $T$ of length $n$ and a pattern string of length $m$, find every consecutive substring $S = T[i..j]$ of a text string $T$ such that $S$ and $P$ Cartesian-tree match. They showed how to solve this problem in $\tilde{O}(n+m)$ time. In this paper, we introduce the Cartesian tree subsequence matching (CTMSeq) problem, that asks to find every minimal substring $S = T[i..j]$ of $T$ such that $S$ contains a subsequence $S'$ which Cartesian-tree matches $P$. We prove that the CTMSeq problem can be solved efficiently, in $O(m n p(n))$ time, where $p(n)$ denotes the update/query time for dynamic predecessor queries. By using a suitable dynamic predecessor data structure, we obtain $O(mn \log \log n)$-time $O(n \log m)$-space solution for CTMSeq. This contrasts CTMSeq with closely related order-preserving subsequence matching (OPMSeq) which was shown to be NP-hard by Bose et al. [IPL 1998].
翻译:Park 等人 。 [TCS 2020] 观察到,两个(数字)字符串之间的相似性可以由Cartesian树的树木捕捉到:一个字符串的Cartesian树是一个二进制树,通过采集作为树根的字符串最小值而重新构造。两个长度相等的字符串在Cartesian-tree 树树是变形的时长。 Park 等人 (TCS 2020) 引入了以下Cartesian 树子字符串匹配(CTMSr) 问题 : 如果文本字符串的长度为$30美元和长度为1美元, 字符串的弦树树树树树树是双双重的, 每连续一个子串的 $S = T[i.j] 美元, 美元和 加元树枝匹配。 它们展示了如何在$tilde{O}(n+m) 时间匹配(CTMSeqeq) 问题,我们要求找到每一个最起码的 C$S 美元更新 美元 美元 。