Abstract

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 \(\sigma \) the alphabet size. We show that the CPH of S, denoted \(\mathsf {CPH}(S)\), supports pattern matching queries in \(O(m (\sigma + \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 \sigma )\) 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 \(\boldsymbol{T}\) with N nodes, we show that the CPH of \(\boldsymbol{T}\), denoted \(\mathsf {CPH}(\boldsymbol{T})\), supports pattern matching queries on the trie in \(O(m (\sigma ^2 + \log (\min \{h, m\})) + occ )\) time with \(O(N \sigma )\) space. We also show a construction algorithm for \(\mathsf {CPH}(\boldsymbol{T})\) running in \(O(N \sigma )\) time and \(O(N \sigma )\) working space.

Full Text
Paper version not known

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call

Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.