Optimal-Time Contextual Pattern Matching in Compressed Space
arXiv:2606.31030
Abstract
Contextual pattern matching is the task of, given a pattern , a context length , and a text , find all the distinct contexts in which occurs in , the context being the symbols preceding and the symbols following the occurrence; a text position where each context occurs must be output. While the problem can be solved in optimal time using -space precomputed data structures on , this type of search is particularly relevant on large repetitive text collections, where space can be prohibitive. We present the first optimal-time solution that runs in compressed space, namely that of a symmetric CDAWG (SCDAWG) of . Further, we show how the set of solutions can be enumerated with delay after -time preprocessing of . To achieve this, we develop an improved linear-space distance-sensitive weighted ancestor data structure.