Linear time online algorithms for constructing linear-size suffix trie

Diptarama Hendrian, Takuya Takagi, Shunsuke Inenaga, Keisuke Goto, Mitsuru Funakoshi

TL;DR

This paper introduces the first linear-time online algorithms to construct Linear-size Suffix Tries (LSTs). Unlike traditional suffix trees, LSTs are "stand-alone" structures that don't require storing the original input string for pattern matching, and these new algorithms can build them incrementally from scratch in $O(n \log \sigma)$ time.

What Problem Does This Paper Address?

In string processing, the suffix tree is the heavyweight champion, allowing for incredibly fast pattern matching. However, it has a hidden cost: to save space, suffix trees store edge labels as pointers to the original text string. This means that even after the tree is built, you must keep the (potentially massive) input string in memory.

Suffix tries, the conceptual ancestors of suffix trees, store actual characters on their edges, making them "stand-alone." The problem? A suffix trie for a string of length $n$ can explode to $O(n^2)$ size.

Linear-size Suffix Tries (LSTs) were proposed in 2016 as a middle ground—they are tries that only use $O(n)$ space. However, until this paper, the only known way to build an LST was an "offline" method: you first had to build a standard suffix tree and then convert it. This defeated the purpose of a memory-efficient, stand-alone structure. The authors set out to create algorithms that build LSTs "directly" and "online" (one character at a time) without ever needing to store the full string or an intermediate suffix tree.

Methods

The authors present two distinct online approaches, mirroring the two classic philosophies of suffix tree construction:

  1. Right-to-Left (Weiner-type): This algorithm processes the string from the end to the beginning. It explicitly creates "Type-2" nodes (auxiliary nodes that maintain the trie structure) where traditional algorithms would use implicit links.
  2. Left-to-Right (Ukkonen-type): This processes the string from start to finish. This is generally more useful for streaming data.

To make pattern matching efficient in an LST, you need "fast links." Maintaining these links while the tree is growing is difficult. The authors solve this by introducing the Edge Link Tree, which is essentially a reversed suffix link tree. They then apply a specialized Nearest Marked Ancestor (NMA) data structure to this tree. This allows them to update and query the structure in $O(1)$ amortized time, keeping the overall construction linear.

Datasets

As a theoretical computer science paper focused on algorithmic complexity and data structure design, no empirical datasets or benchmarks were used. The validity of the work is established through mathematical proofs of time and space complexity.

Key Insights and Ideas

  • The "Stand-Alone" Advantage: The primary "aha!" moment is that by carefully choosing which nodes from a massive suffix trie to keep (Type-1 branching nodes and specific Type-2 auxiliary nodes), you can achieve $O(n)$ space while keeping edge labels as single characters.
  • Direct Construction: By bypassing the suffix tree entirely, the algorithm allows for a truly "streaming" workflow where the input character can be discarded immediately after being processed.
  • NMA for Fast Links: The realization that maintaining "fast links" (crucial for $O(|P| \log \sigma)$ matching) can be reduced to a dynamic Nearest Marked Ancestor problem on a growing tree is the core technical innovation that makes the left-to-right version efficient.

Key Results

  • Time Complexity: Both the right-to-left and left-to-right algorithms run in $O(n \log \sigma)$ time, where $n$ is the string length and $\sigma$ is the alphabet size.
  • Space Complexity: The algorithms use $O(n)$ working space.
  • Online Property: The LST is updated incrementally as each new symbol is read, without ever accessing previously read symbols or needing to store the input string $T$.

Limitations and Future Work

  • Alphabet Dependency: The $O(\log \sigma)$ factor comes from the need to branch at nodes. While standard for general alphabets, it's a slight overhead compared to $O(n)$ algorithms for constant-sized or integer alphabets.
  • CDAWG Extensions: The authors suggest that their techniques could potentially be extended to Compact Directed Acyclic Word Graphs (CDAWGs), which are even more space-efficient than suffix trees but much harder to build online.
  • Practical Implementation: While theoretically optimal, the paper does not provide an empirical comparison of the constant factors involved in LST construction versus traditional suffix tree construction. Future work could explore how these structures perform in real-world genomic or large-scale text databases.

Summary updated

BibTeX
@article{hendrian2024linear,
  author = {Diptarama Hendrian and Takuya Takagi and Shunsuke Inenaga and Keisuke Goto and Mitsuru Funakoshi},
  title = {{Linear time online algorithms for constructing linear-size suffix trie}},
  journal = {Theoretical Computer Science},
  year = {2024},
  doi = {10.1016/j.tcs.2024.114765},
}
Figure