Online Algorithms for Constructing Linear-Size Suffix Trie

Diptarama Hendrian, Takuya Takagi, Shunsuke Inenaga

Introduction

In string processing, the Suffix Tree is a fundamental data structure, allowing pattern matching in time proportional to the pattern length. However, to maintain a linear $O(n)$ space complexity, suffix trees store edge labels as index pairs referencing the original text. This dependency requires the original string to remain in memory, which is problematic for massive datasets or memory-constrained environments.

Suffix Tries offer a "stand-alone" alternative by storing actual characters on edges. Unfortunately, a standard suffix trie can reach $O(n^2)$ size. Linear-size Suffix Tries (LSTs), introduced by Crochemore et al. in 2016, solve this by using auxiliary nodes to maintain $O(n)$ size while remaining stand-alone. This paper presents the first "online" algorithms to construct LSTs directly, symbol-by-symbol.

Comparison of Suffix Trie, Linear-size Suffix Trie, and Suffix Tree.

The Stand-Alone Advantage

The LST's primary advantage is its independence from the input text. By ensuring every edge represents exactly one character, the LST removes the need to store the original string alongside the index. This is a game-changer for systems where memory is tight or where the original text is too massive to keep in RAM alongside the index.

Online Construction Algorithms

The authors propose two distinct online construction methods:

1. Right-to-Left (R-to-L) Construction

Based on Weiner’s algorithm, this method processes the string from end to beginning. It utilizes "hard" and "soft" Weiner links to identify insertion points for new nodes. The algorithm distinguishes between Type-1 nodes (standard branching nodes) and Type-2 nodes (auxiliary nodes that break long edges into single-character steps).

Right-to-left LST construction showing the addition of nodes and reversed suffix links.

2. Left-to-Right (L-to-R) Construction

Based on Ukkonen’s algorithm, this "streaming" approach processes the string from start to finish. It introduces a "pre-LST" structure and uses "fast links" (chains of suffix links) to efficiently update the active point in the trie as new characters arrive.

Key Technical Innovation: Type-2 Nodes

The core innovation lies in the management of Type-2 nodes. These nodes ensure the trie remains linear in size without sacrificing the stand-alone property. The authors rigorously prove that the total number of nodes remains bounded by $O(n)$, specifically showing that the number of Type-2 nodes is at most $n-1$.

Performance and Complexity

The authors established the following asymptotic bounds for their algorithms (where $n$ is string length and $\sigma$ is alphabet size):

  • R-to-L Algorithm: Runs in $O(n \log \sigma)$ time and $O(n)$ space.
  • L-to-R Algorithm: Runs in $O(n(\log \sigma + \frac{\log n}{\log \log n}))$ time and $O(n)$ space.
  • Pattern Matching: Once constructed, the LST supports pattern matching for a pattern $P$ in $O(|P| \log \sigma)$ time using "fast links," matching the efficiency of a suffix tree.

Conclusion and Future Work

This work successfully adapts Weiner and Ukkonen construction philosophies to the LST framework, proving that the LST is a robust alternative to the suffix tree. Future challenges include closing the complexity gap for the L-to-R algorithm and extending these techniques to even more compact structures like Linear-size Compact DAWGs (LCDAWGs).

Summary updated

Abstract

The suffix trees are fundamental data structures for various kinds of string processing. The suffix tree of a string T of length n has O(n) nodes and edges, and the string label of each edge is encoded by a pair of positions in T. Thus, even after the tree is built, the input text T needs to be kept stored and random access to T is still needed. The linear-size suffix tries (LSTs), proposed by Crochemore et al. [Linear-size suffix tries, TCS 638:171-178, 2016], are a "stand-alone" alternative to the suffix trees. Namely, the LST of a string T of length n occupies O(n) total space, and supports pattern matching and other tasks in the same efficiency as the suffix tree without the need to store the input text T. Crochemore et al. proposed an offline algorithm which transforms the suffix tree of T into the LST of T in O(n log sigma) time and O(n) space, where sigma is the alphabet size. In this paper, we present two types of online algorithms which "directly" construct the LST, from right to left, and from left to right, without constructing the suffix tree as an intermediate structure. Both algorithms construct the LST incrementally when a new symbol is read, and do not access to the previously read symbols. The right-to-left construction algorithm works in O(n log sigma) time and O(n) space and the left-to-right construction algorithm works in O(n (log sigma + log n / log log n)) time and O(n) space. The main feature of our algorithms is that the input text does not need to be stored.
BibTeX
@inproceedings{hendrian2019online,
  author = {Diptarama Hendrian and Takuya Takagi and Shunsuke Inenaga},
  title = {{Online Algorithms for Constructing Linear-Size Suffix Trie}},
  booktitle = {CPM},
  year = {2019},
  url = {https://openreview.net/forum?id=sa8Ik2vyZO},
}
Figure