Abstract
Finding the $k$ closest consecutive occurrences of a pattern in a text is a fundamental problem in string indexing with applications in bioinformatics and data mining. We present the first efficient data structures for the String Indexing for Top-k Close Consecutive Occurrences (SITCCO) problem. By combining heavy path decomposition, geometric reduction to 2D segment intersection, and recursive tree clustering, we achieve various time-space tradeoffs, including an optimal $O(m+k)$ query time solution and a linear space solution.
Introduction
Standard string indexing techniques, such as Suffix Trees and Suffix Arrays, are designed to locate all occurrences of a pattern $P$ in a text $T$. However, many applications require analyzing the proximity of these occurrences. The SITCCO problem asks for the $k$ pairs of consecutive occurrences $(i, j)$—where $P$ appears at $i$ and $j$ with no occurrences in between—that minimize the distance $j - i$.
A significant challenge in SITCCO is that the set of closest pairs for a pattern does not easily relate to the closest pairs for its extensions (e.g., the closest pairs for "AN" vs. "ANA"). This "non-decomposability" prevents the direct application of standard range-minimum query techniques. Before this work, the primary solution involved finding and sorting all occurrences, which is inefficient when the pattern appears frequently.
Geometric Reduction
The core of the proposed solution is a transformation of the string problem into a 2D computational geometry problem. Each consecutive occurrence is modeled as a vertical line segment in a plane. The $x$-axis represents the distance between occurrences, and the $y$-axis represents the depth in the Suffix Tree, which corresponds to the pattern length.
By treating distance as a spatial coordinate, finding the top-$k$ closest occurrences becomes a "smallest-segments" intersection query. The authors prove that as one moves down a path in the Suffix Tree, the set of consecutive occurrences changes at most $O(n \log n)$ times, enabling efficient persistence and query processing.
Advanced Tree Decomposition and Clustering
To achieve space efficiency, the authors employ two primary techniques: Heavy Path Decomposition and Recursive Tree Clustering. Heavy path decomposition linearizes the tree structure into manageable segments. Recursive clustering partitions the Suffix Tree into a hierarchy of subtrees with doubly exponentially decreasing sizes.
This clustering allows the data structure to store detailed geometric information only where necessary. Large global coordinates are mapped to small local offsets within clusters through Rank Space Reduction, significantly reducing the bit-width of stored pointers and overall space consumption.
Results and Tradeoffs
As a theoretical contribution, this work provides mathematical proofs for the time and space complexity of the proposed algorithms. The paper establishes three primary time-space tradeoffs for a text of length $n$, pattern length $m$, and result size $k$:
- Optimal Query Time: $O(n \log n)$ space with $O(m + k)$ query time.
- Linear Space (Tradeoff A): $O(n/\epsilon)$ space with $O(m + k^{1+\epsilon})$ query time.
- Linear Space (Tradeoff B): $O(n/\epsilon)$ space with $O(m + k \log^{1+\epsilon} n)$ query time.
These results also extend to finding the $k$ farthest consecutive occurrences and patterns with specific gap constraints.
Conclusion
This work provides the first efficient solutions for the SITCCO problem by bridging string algorithms and geometric data structures. While the theoretical bounds are optimal or near-optimal, the practical implementation of these structures—particularly the recursive clustering—remains a task for future research. A major open question is whether it is possible to achieve linear space and optimal $O(m + k)$ query time simultaneously.
Summary updated