Approximate Cartesian Tree Matching with Substitutions
Abstract
The Cartesian tree of a sequence captures the relative order of the sequence's elements. In recent years, Cartesian tree matching has attracted considerable attention, particularly due to its applications in time series analysis. Consider a text of length and a pattern of length . In the exact Cartesian tree matching problem, the task is to find all length- fragments of whose Cartesian tree coincides with the Cartesian tree of the pattern. Although the exact version of the problem can be solved in linear time [Park et al., TCS 2020], it remains rather restrictive; for example, it is not robust to outliers in the pattern. To overcome this limitation, we consider the approximate setting, where the goal is to identify all fragments of that are close to some string whose Cartesian tree matches . In this work, we quantify closeness via the widely used Hamming distance metric. For a given integer parameter , we present an algorithm that computes all fragments of that are at Hamming distance at most from a string whose Cartesian tree matches . Our algorithm runs in time for and in time for , thereby improving upon the state-of-the-art -time algorithm of Kim and Han [TCS 2025] in the regime . On the way to our solution, we develop a toolbox of independent interest. First, we introduce a new notion of periodicity in Cartesian trees. Then, we lift multiple well-known combinatorial and algorithmic results for string matching and periodicity in strings to Cartesian tree matching and periodicity in Cartesian trees.
Cite
@article{arxiv.2602.08570,
title = {Approximate Cartesian Tree Matching with Substitutions},
author = {Panagiotis Charalampopoulos and Jonas Ellert and Manal Mohamed},
journal= {arXiv preprint arXiv:2602.08570},
year = {2026}
}
Comments
Full version of a work to appear in the proceedings of STACS 2026