TL;DR
This paper introduces two new algorithms for sparse suffix sorting that are designed to be "simple, direct, small, and fast." By avoiding the construction of complex intermediate data structures like suffix trees, the authors provide a practical, memory-efficient solution that matches the theoretical performance of optimal algorithms while being significantly easier for engineers to implement.
What Problem Does This Paper Address?
Suffix sorting—arranging all suffixes of a string in lexicographical order—is a fundamental task in text indexing, bioinformatics, and data compression. In many modern applications, we only need to sort a sublinear number ($b$) of suffixes out of a total string length ($n$). This is known as sparse suffix sorting.
While theoretically optimal $O(n)$-time algorithms for this problem have existed for years, they are rarely used in practice. The authors argue this is because existing solutions are either:
- Indirect: They require building a complex "sparse suffix tree" first.
- Complex: They rely on intricate partitioning schemes or advanced data structures that are difficult to implement correctly and efficiently.
- Memory-Heavy: They often carry high constants in space usage, making them impractical for massive datasets like the human genome.
The authors aim to bridge this gap between theory and practice by providing algorithms that use only basic data structures (like dictionaries and arrays) and minimal extra memory.
Methods
The paper presents two primary algorithms: Main-Algo and Parameterized-Algo.
1. Main-Algo
This algorithm is based on a partition refinement strategy. It starts with all suffixes in a single group and iteratively refines them based on their prefixes.
- Karp-Rabin Fingerprints: To compare suffixes efficiently, the algorithm uses rolling hashes (fingerprints). In each iteration $j$, it compares prefixes of length $2^j$.
- Hashing: Instead of complex "distribute-and-collect" techniques, it uses standard hashing to group suffixes with identical fingerprints in $O(b)$ time.
- Direct Construction: Once the refinement is complete, it performs a simple depth-first search (DFS) on the resulting hierarchy to output the Sparse Suffix Array (SSA) and the Sparse Longest Common Prefix (SLCP) array directly.
2. Parameterized-Algo (PA)
This is an "input-sensitive" version of the algorithm. It recognizes that in most real-world datasets, very few suffixes share extremely long prefixes.
- It first performs a "quasi-sort" using a lower number of iterations.
- It then identifies only the "difficult" suffixes—those that still share long prefixes—and performs a second, targeted sorting pass on just that subset.
- This allows the algorithm to run in $O(n)$ time for most practical instances.
Datasets
The authors evaluated their implementations (MA and PA) against the only other publicly available implementation (SSA-LCE by Prezza) using three large-scale datasets:
- FASTQ: 11 GB of human DNA reads (high alphabet size, complex structure).
- AMAZON: 10.23 GB of Amazon product reviews (natural language text).
- RANDOM: 5 GB of synthetically generated random characters (used as a baseline).
Key Insights and Ideas
- Simplicity is a Feature: By using basic data structures like
std::vectorand standard hash maps, the authors created a tool that is actually usable by practitioners without sacrificing theoretical bounds. - The Power of Hashing: Moving from deterministic grouping to Monte Carlo hashing significantly simplifies the implementation and improves practical speed.
- Input Sensitivity Matters: The "aha moment" for Parameterized-Algo is that you don't need to treat every suffix with the same level of scrutiny. Sorting the "easy" ones quickly and focusing resources on the "hard" ones (those with long shared prefixes) yields massive performance gains on real-world data.
Key Results
The experimental results demonstrate that their Parameterized-Algo (PA) is a significant improvement over the state-of-the-art:
- Speed: PA is up to 2x faster than the existing SSA-LCE implementation and significantly faster than the basic Main-Algo.
- Memory: In sparse instances, PA and MA use about half the memory of SSA-LCE. PA requires only $8b + o(b)$ machine words of extra space.
- Scalability: The runtime scales linearly with the string length $n$, making it suitable for multi-gigabyte datasets.
Limitations and Future Work
- Monte Carlo Nature: The algorithms are probabilistic. While the probability of error is extremely low (controlled by the prime chosen for Karp-Rabin fingerprints), they are not deterministic.
- Dense Instances: In "dense" cases (where $b$ is a large fraction of $n$), the memory footprint of these algorithms grows linearly with $b$. In these specific scenarios, "restore model" algorithms that overwrite the input string might still be more space-efficient, though they are generally slower.
- Future Directions: The authors suggest that their simple framework could be adapted for other string processing tasks or further optimized for specific hardware architectures.
Summary updated