CS Paper Radar

String Indexing for Maximal Gap-Bounded Occurrence Clusters

Waseem Akram, Takuya Mieno

cs.DS ·submitted 2026-11-21 11:09 UTC · v1
published

Abstract

Repeated occurrences of a pattern can form groups that reveal where repetition is concentrated in a text. We study how to find such groups efficiently when both the pattern $P$ and the distance threshold $G$ between occurrences are specified as query parameters. A maximal $G$-cluster of $P$ is a maximal block of at least two occurrences of $P$ whose consecutive starting positions differ by at most $G$. In this paper, we present indexes for reporting all cluster intervals and counting the clusters. For a text of length $n$ and a pattern of length $m$, we propose an $O(n\log n)$-space index that reports all maximal cluster intervals in $O(m+\log\log n+\mathit{output})$ time, where $\mathit{output}$ is the number of reported intervals, and that counts the clusters in $O(m+\log\log n)$ time. Restricting occurrences to those fully contained in a query substring preserves the reporting time using $O(n\log^2 n)$ space. Our indexes combine suffix-tree decompositions with geometric reporting queries on consecutive gaps.

Comment
Appears in the Proceedings of the 52nd International Conference on Current Trends in Theory and Practice of Computer Science (Sofsem 2027)

Closest papers

Nearest neighbours by meaning across the whole index.

Internal Queries for Maximal Closed Substrings

cs.DS ·2026-11-08 ·Simone Faro, Francesco Pio Marino, Arianna Pavone
theory similarity 0.68
Abstract

Searching for repetitions inside a selected part of a text raises a subtle boundary problem: removing neighbouring characters can create new maximal answers. We study this effect for maximal closed substrings (MCSs). A string is closed if it is a single letter or has a nonempty proper prefix occurring exactly twice, as its prefix and suffix; a closed occurrence is maximal if neither available one-character extension is closed. Previous work established $O(n\log n)$ bounds on the global MCS families of a length-$n$ text and developed enumeration algorithms. Internal queries instead ask for the MCSs of a chosen substring, with maximality evaluated inside that substring. Separating boundary occurrences from interior ones gives an $O(n\log n)$-word index that reports the $c$ answers in $O(\log n+c)$ time and supports counting and longest queries in $O(\log n)$ time. Our main result reduces reporting space to $O(n)$ words, with $O((c+1)\log^{1+\varepsilon} n)$ query time and $O(n\log^{1+\varepsilon} n)$ construction time for any fixed $\varepsilon>0$. Thus, after preprocessing, reporting requires no additive scan of the queried substring, which is particularly useful for long queries with few answers. Independently, we prove that at most $3(s-1)$ MCS occurrences of any length-$s$ substring cross a fixed gap between consecutive characters, with maximality evaluated inside that substring. The same bound holds for global MCSs contained in a length-$s$ block. A family over two letters attains $\lfloor(s-1)/2\rfloor$ crossings for every $s\ge3$, showing that the linear order of this local density bound is optimal.

0.10

Space-Efficient Text Indexing for Advanced Counting Queries

cs.DS ·2026-11-20 ·Solon P. Pissis, Sharma V. Thankachan
similarity 0.68
Abstract · SOSA 2027 (abstract abridged to satisfy arXiv requirements)

In the classical problem of text indexing, the objective is to preprocess a text $T=T[1..n]$ over an integer alphabet $[0..σ)$ into a data structure that supports efficient pattern matching queries. Given a pattern $P=P[1..m]$, a reporting query lists the set $\mathsf{Occ}_T(P)$ of occurrences of $P$ in $T$, whereas a counting query returns $|\mathsf{Occ}_T(P)|$. Space-efficient suffix-tree variants use only $\mathcal{O}(n\logσ)$ bits and support reporting queries in $\mathcal{O}(m+|\mathsf{Occ}_T(P)|\cdot\log_σ^ε n)$ time, where $ε>0$ is an arbitrarily small constant, and counting queries in $\mathcal{O}(m)$ time. Notably, space-efficient indexes for more advanced counting queries have largely resisted achieving the same optimal (or near-optimal) query times when using less than $Θ(n\log n)$ bits. We change this situation by proposing a general framework that supports advanced counting queries, denoted by $φ_T(P)$, provided that $φ_T$ satisfies two mild conditions: (1) $φ_T(P)$ is an integer in $[0..|\mathsf{Occ}_T(P)|]$ that can be computed from $\mathsf{Occ}_T(P)$ via sorting; and (2) $φ_T(Q)\geqφ_T(P)$ for every prefix $Q$ of $P$. We show that our framework supports optimal $\mathcal{O}(m)$-time queries using $\mathcal{O}(n\logσ+n(\log\log n)^2)$ bits or near-optimal $\mathcal{O}(m\log_σ^ε n)$-time queries using $\mathcal{O}(n\logσ)$ bits. As an example, our trade-offs improve upon the classical MAST index for counting non-overlapping occurrences [Apostolico and Preparata, Algorithmica, 1996; Brodal et al., ICALP 2002], which uses $\mathcal{O}(n\log n)$ bits and supports $\mathcal{O}(m)$-time queries, and the recent compact index for the same problem [Bals et al., ESA 2026], which uses $\mathcal{O}(n\logσ)$ bits and supports $\mathcal{O}(m\log n\log_σ^ε n)$-time queries.

0.26

Output-Sensitive Enumeration of Maximal Closed Substrings in Linear Space

cs.DS ·2026-10-28 ·Johannes Fischer, Dominik Köppl
similarity 0.65
Abstract

We revisit the output-sensitive enumeration of maximal closed substrings (MCSs). Given a string of length $n$ over an integer alphabet, let $k$ denote its number of MCS occurrences. We combine a right-to-left sweep on the string with range-successor queries to obtain all MCSs with two deterministic word-RAM bounds: for any fixed $\varepsilon>0$, we can report all MCSs in $O(n\sqrt{\log n}+k\log^\varepsilon n)$ time using $O(n)$ words of space, or in $O(n\sqrt{\log n}+k\log\log n)$ time using $O(n\log\log n)$ words. Both bounds include preprocessing and report occurrences by their endpoints. In particular, these algorithms improve the known $O(n\log n)$ worst-case time bound for sufficiently small output.

0.53

Joining Large String Collections with Jaro-Winkler Similarity

cs.DB ·2026-10-16 ·Manuel Lankes, Daniel Kocher, Daniel Schmitt, Willi Mann, Thomas Samy Dafir +3 more
top venue similarity 0.62
Abstract · Accepted for publication in Proc. ACM Manag. Data (PACMMOD / SIGMOD 2027). Please cite the official version: https://doi.org/10.1145/3856354

The Jaro-Winkler measure, originally developed for U.S.\ Census record linkage, captures similarities between strings and accounts for common typographical variations. Despite its widespread use, finding all string pairs that exceed a given Jaro-Winkler threshold remains challenging as the string collection grows large. Existing algorithms for computing the Jaro-Winkler similarity between two strings are either slow for short strings or require quadratic time and fail to scale to long strings. To reduce the number of string comparisons, state-of-the-art techniques perform an index-nested-loop join on trie-based indexes; however, they have only been evaluated on small datasets and high similarity thresholds. For lower similarity thresholds that are relevant in practice, these techniques incur an excessive number of costly Jaro-Winkler computations. We present a novel approach for efficient Jaro-Winkler similarity joins on large string collections. Our solution is based on three key techniques: (1) JUMP is a fast algorithm for computing the Jaro-Winkler similarity between two strings that runs in linear time for bounded alphabets. (2) Dual-bound intersection bitmaps encode strings -- represented as character sets -- into fixed-size bitmaps, which are used to prune candidate string pairs by providing effective bounds on their character overlap; unlike prior bitmap techniques, our bitmaps are equipped with a cost model and adapt to the input data. (3) Our PUMA framework groups strings by prefix to tighten filter conditions, thereby reducing the number of similarity computations. Extensive experiments on large string collections demonstrate that our approach consistently outperforms the state of the art, achieving speedups of up to three orders of magnitude.

0.43

Real-Time String Indexing in Optimal Time

cs.DS ·2026-11-10 ·Gregory Kucherov, Yakov Nekrich
similarity 0.61
Abstract · 30 pages, 7 figures

In this paper we describe the first fully real-time indexing solution for pattern matching over an arbitrary integer alphabet. Our data structure spends $O(1)$ worst-case time w.h.p. for processing each new letter appended to $T$ and worst-case $O(|P|+occ)$ time for reporting all occurrences of $P$, where $T$ and $P$ are strings over an integer alphabet. The main idea of our solution is a novel representation of the suffix tree, the path-decomposed suffix tree, which does not store the full topology of the suffix tree but instead decomposes it into paths, each stored in a dictionary that encodes parent--child relationships indirectly.

0.39

Location-Aware Matching Statistics

cs.DS cs.DB ·2026-11-23 ·Lorraine A. K. Ayad, Grigorios Loukides, Solon P. Pissis
similarity 0.61
Abstract

Edit distance is the standard measure of string similarity, but its quadratic-time complexity is prohibitive for long strings. Popular linear-time alternatives, such as the $q$-gram distance, or the average common substring measure (ACS) that is based on matching statistics (MS), consider the substrings shared by the two input strings but not where they occur in each string. Yet in many real-world applications, e.g., when comparing document versions or co-recorded time series, a shared substring is really relevant only if its occurrences are close in position. We introduce Location-Aware Matching Statistics (LAMAS). Given strings $X$ and $Y$ and a displacement tolerance $d$, LAMAS reports, for every position $i$ of $Y$, the longest substring starting at $i$ that occurs in $X$ at a position $j$ with $|j-i|\le d$, together with the displacement $(j-i)$. MS is the special case of LAMAS with unbounded $d$. Our main result is an algorithm that solves LAMAS in $\mathcal{O}(n)$ time and space for strings of length at most $n$ and any $d$; this is optimal and matches the complexity of MS. The algorithm reduces LAMAS to predecessor and successor queries over a sliding window of suffix ranks and answers them in linear total time via a window decomposition and interval union-find. Experiments on 20 real datasets and synthetic data show that LAMAS substantially improves over MS and $q$-gram distance in similarity-based classification, top-$K$ retrieval, and clustering. It is competitive with edit distance and a constrained dynamic time warping variant in classification and generally outperforms a state-of-the-art method for top-$K$ retrieval under edit distance. Finally, our implementation of the main algorithm for LAMAS scales linearly in $n$ and does not slow down as $d$ grows.

0.31

ZigZag Trie: A Novel Index for Contextual Queries

cs.DS cs.DB ·2026-09-17 ·Ling Li, Daniel Gibney, Sharma V. Thankachan, Rahul Shah, Grigorios Loukides +1 more
similarity 0.60
Abstract · 29 pages

There is increasing interest in queries about the context of a string $P$ in a longer text $T$, i.e., the set of all string pairs $(L,R)$, with $|L|=|R|=q$, for a given $q$, such that the string $LPR$ occurs in $T$. Such contextual queries are important in several domains but are challenging to answer efficiently. This is because the length of $T$ in applications is massive and existing indexes do not directly encode the context of a given $P$, which is key for answering retrieval queries efficiently. Our work introduces the ZigZag Trie (ZZT), a new full-text index to specifically address these challenges. This index reorganizes the text so that, for any $P$, all possible strings $L$ and $R$ growing symmetrically around $P$ are grouped into a common subtree of the index, allowing their efficient retrieval. We show how to construct the ZZT of $T$, which has size $\mathcal{O}(n)$ where $n=|T|$, in $\mathcal{O}(n\log n)$ time and $\mathcal{O}(n)$ space. On top of ZZT, we design specialized indexes that, for a query pattern $P$, answer four new types of contextual queries: (I) finding the longest string $LPR$ that occurs at least $τ$ times in $T$, for a fixed $τ$; (II) finding the longest string $LPR$ that occurs in at least $τ$ texts of a text collection, for a fixed $τ$; (III) reporting the total number of distinct contexts of $P$ in $T$; and (IV) retrieving, for a given $q$, the $k$ pairs $(L,R)$ of $P$ with the highest scores according to a given scoring function. Our indexes answer queries of type I, II, and III in optimal time, and of type IV in near-optimal time. Moreover, their size, construction space, and construction time are linear or near-linear in $n$, given ZZT. Using real billion-letter datasets, we show that our indexes answer queries orders of magnitude faster than baselines and perform similarly or better in index size and construction space and time.

0.33

Longest Unbordered Factors in Linear Time

cs.DS ·2026-11-09 ·Takuya Mieno
similarity 0.59
Abstract

A border of a string is a nonempty proper prefix that is also a suffix. A string is unbordered if it has no border. The length of a longest unbordered factor is closely related to the smallest period of the string. While the smallest period can be computed in linear time, the best previously known algorithm for computing a longest unbordered factor takes $O(n \log n)$ worst-case time for a string of length $n$. Whether this computational problem can be solved in worst-case linear time has remained open. In this paper, we resolve this open problem for integer alphabets of size $n^{O(1)}$ by presenting an algorithm that computes all occurrences of longest unbordered factors in $O(n)$ worst-case time. Our algorithm uses a combinatorial property of longest unbordered factors and scans the input string in both directions to capture all occurrences achieving the global maximum without computing the local maximum at every starting position.

0.28