Position Heaps for Cartesian-Tree Matching on Strings and Tries
Position Heaps for Cartesian-Tree Matching on Strings and Tries
复制标题
字符串和尝试上笛卡尔树匹配的位置堆
DOI:
10.1007/978-3-030-86692-1_20
复制
发表时间:
2021
期刊:
影响因子:
--
通讯作者:
Shunsuke Inenaga
中科院分区:
文献类型:
--
作者:
Akio Nishimoto;Noriki Fujisato;Yuto Nakashima;Shunsuke Inenaga
TheCartesian-tree pattern matchingis 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'$$ S ′ of the text stringSsuch that the Cartesian tree of $$S'$$ S ′ and that of a query patternPcoincide. In this paper, we present a new indexing structure for this problem, called theCartesian-tree Position Heap(CPH). Letnbe the length of the input text stringS,mthe length of a query patternP, and $$\sigma $$ σ the alphabet size. We show that the CPH ofS, denoted $$\mathsf {CPH}(S)$$ CPH ( S ) , supports pattern matching queries in $$O(m (\sigma + \log (\min \{h, m\})) + occ )$$ O ( m ( σ + log ( min { h , m } ) ) + o c c ) time withO(n) space, wherehis the height of the CPH and $$ occ $$ occ is the number of pattern occurrences. We show how to build $$\mathsf {CPH}(S)$$ CPH ( S ) in $$O(n \log \sigma )$$ O ( n log σ ) time withO(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 $$\boldsymbol{T}$$ T withNnodes, we show that the CPH of $$\boldsymbol{T}$$ T , denoted $$\mathsf {CPH}(\boldsymbol{T})$$ CPH ( T ) , supports pattern matching queries on the trie in $$O(m (\sigma ^2 + \log (\min \{h, m\})) + occ )$$ O ( m ( σ 2 + log ( min { h , m } ) ) + o c c ) time with $$O(N \sigma )$$ O ( N σ ) space. We also show a construction algorithm for $$\mathsf {CPH}(\boldsymbol{T})$$ CPH ( T ) running in $$O(N \sigma )$$ O ( N σ ) time and $$O(N \sigma )$$ O ( N σ ) working space.