字符串和Tries上Cartesian树匹配的位置堆
Position Heaps for Cartesian-tree Matching on Strings and Tries
摘要:
Cartesian树模式匹配是最近引入的模式匹配方案,其检测具有与查询模式相似的结构的连续数据流中的片段。形式上,笛卡尔树模式匹配寻找文本串$S$的所有子串$S'$,使得$S'$的笛卡尔树与查询模式$P$的笛卡尔树一致。在本文中,我们提出了一个新的索引结构,这个问题称为笛卡尔树位置堆(CPH)。令$n$为输入文本字符串$S$的长度,$m$为查询模式$P$的长度,$σ$为字母表大小。我们发现,CPH的$S$,表示$\mathsf{CPH}(S)$,支持模式匹配查询在$O(m (σ+ \log (\min\{h, m\})) + occ)$时间与$O(n)$空间,其中$h$是高度的CPH和$occ$是模式出现的次数。我们展示了如何在$O(n)$工作空间的$O(n \log σ)$时间内构建$\mathsf{CPH}(S)$。此外,我们将问题扩展到文本是标记树(即Trie)的情况。给定一个trie $T$与$N$节点,我们表明,CPH的$T$,表示$\mathsf{CPH}(T)$,支持模式匹配查询的trie在$O(m (σ^2 + \log (\min\{h, m\})) + occ)$时间与$O(N σ)$空间。我们还展示了一个运行在$O(N σ)$时间和$O(N σ)$工作空间中的$\mathsf{CPH}(T)$的构造算法。
英文摘要:
The Cartesian-tree pattern matching is a recently introduced scheme of pattern matching that detects fragments in a sequential data stream which have a similar structure as a query pattern. Formally, Cartesian-tree pattern matching seeks all substrings $S'$ of the text string $S$ such that the Cartesian tree of $S'$ and that of a query pattern $P$ coincide. In this paper, we present a new indexing structure for this problem called the Cartesian-tree Position Heap (CPH). Let $n$ be the length of the input text string $S$, $m$ the length of a query pattern $P$, and $σ$ the alphabet size. We show that the CPH of $S$, denoted $\mathsf{CPH}(S)$, supports pattern matching queries in $O(m (σ+ \log (\min\{h, m\})) + occ)$ time with $O(n)$ space, where $h$ is the height of the CPH and $occ$ is the number of pattern occurrences. We show how to build $\mathsf{CPH}(S)$ in $O(n \log σ)$ time with $O(n)$ working space. Further, we extend the problem to the case where the text is a labeled tree (i.e. a trie). Given a trie $T$ with $N$ nodes, we show that the CPH of $T$, denoted $\mathsf{CPH}(T)$, supports pattern matching queries on the trie in $O(m (σ^2 + \log (\min\{h, m\})) + occ)$ time with $O(N σ)$ space. We also show a construction algorithm for $\mathsf{CPH}(T)$ running in $O(N σ)$ time and $O(N σ)$ working space.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。