Suffix Trays and Suffix Trists: Structures for Faster Text Indexing

Richard Cole, Tsvi Kopelowitz, Moshe Lewenstein

TL;DR

This paper introduces "suffix trays" and "suffix trists," novel data structures that combine the strengths of suffix trees and suffix arrays to achieve faster text indexing. These structures offer deterministic query times of $O(m + \log |\Sigma|)$ for static texts and $O(m + \log |\Sigma|)$ for online text extensions, improving upon existing methods while maintaining linear space and construction time.

What Problem Does This Paper Address?

Text indexing is crucial for efficiently searching for patterns within large texts. Two dominant data structures for this task are suffix trees and suffix arrays. While both can be built in linear time and space, they have different query time complexities. Suffix trees typically offer $O(m \log |\Sigma| + occ)$ query time (where $m$ is query length, $|\Sigma|$ is alphabet size, and $occ$ is the number of occurrences), while suffix arrays achieve $O(m + \log n + occ)$ (where $n$ is text length). The paper aims to bridge this gap by developing data structures that offer the best of both worlds: deterministic, fast query times comparable to suffix arrays, but with the structural advantages of suffix trees, and also address the challenge of online text indexing where the text grows character by character.

Methods

The paper introduces two main data structures:

  • Suffix Tray: This structure combines suffix trees and suffix arrays by leveraging the concept of "suffix intervals." It introduces special "suffix interval nodes" and utilizes arrays at "branching-σ-nodes" (nodes in the suffix tree with at least $|\Sigma|$ leaves in their subtree) to facilitate faster navigation. The key idea is to efficiently map query characters to relevant parts of the suffix array, achieving $O(m + \log |\Sigma|)$ query time. Construction is linear.
  • Suffix Trist: This is an online version of the suffix tray designed for scenarios where the text arrives character by character. It replaces the static suffix array with dynamic data structures (balanced indexing structures or BISs) that can handle insertions. The suffix trist aims to mimic the suffix tray's query performance while supporting efficient text extensions. The update time for text extensions depends on the underlying online suffix tree construction, with a bound of $O(f(n, |\Sigma|) + \log |\Sigma|)$, where $f(n, |\Sigma|)$ is the cost of adding a character to the suffix tree.

Datasets

Not discussed in the paper. The paper focuses on theoretical data structure design and analysis rather than empirical evaluation on specific datasets.

Key Insights and Ideas

  • Bridging Suffix Trees and Suffix Arrays: The core insight is that by carefully combining the hierarchical structure of suffix trees with the ordered nature of suffix arrays (via suffix intervals), one can achieve query times that outperform either structure individually for certain scenarios.
  • Suffix Intervals as a Unifying Concept: The paper effectively uses suffix intervals, derived from suffix tree nodes, to connect the tree structure to contiguous ranges in the suffix array. This connection is fundamental to both the suffix tray and trist.
  • σ-Nodes for Efficient Partitioning: The introduction of σ-nodes (nodes with at least $|\Sigma|$ leaves) and their classification (branching-σ-nodes, σ-leaves) provides a principled way to partition the suffix tree and manage auxiliary data structures (like arrays $A_v$) for efficient query routing.
  • Lazy Updates for Dynamic Structures: For the online suffix trist, the paper proposes a "lazy" approach to constructing the branching-σ-node arrays ($A_v$), deferring the cost of construction to future insertions. This is crucial for maintaining efficient update times in a dynamic setting.

Key Results

  • Suffix Tray:
    • Linear space complexity ($O(n)$).
  • Linear construction time ($O(n)$).
  • Deterministic query time of $O(m + \log |\Sigma|)$ for patterns of length $m$.
  • Supports outputting all occurrences with an additional $O(occ)$ cost.
  • Suffix Trist:
    • Linear space complexity ($O(n)$).
  • Supports online text extensions with a cost of $O(f(n, |\Sigma|) + \log |\Sigma|)$, where $f(n, |\Sigma|)$ is the cost of extending an online suffix tree.
  • Supports indexing queries in $O(m + \log |\Sigma|)$ time.

Limitations and Future Work

  • Alphabet Size Dependency: The query time for the suffix tray is $O(m + \log |\Sigma|)$, which means it can be slower than $O(m + \log n)$ if the alphabet size $|\Sigma|$ is significantly larger than the text size $n$. The paper notes that this can be improved for integer alphabets from a linear range.
  • Online Construction Dependency: The efficiency of the suffix trist for text extensions is dependent on the existence and performance of an underlying online suffix tree construction algorithm.
  • Future Work: The authors explicitly mention that a significant future challenge is to allow deletions of texts from a collection, in addition to insertions, for generalized suffix trists. They also suggest exploring generalized suffix trists for managing collections of texts.

Summary updated

Abstract

Suffix trees and suffix arrays are two of the most widely used data structures for text indexing. Each uses linear space and can be constructed in linear time for polynomially sized alphabets. However, when it comes to answering queries with worst-case deterministic time bounds, the prior does so in $O(m\log|\Sigma|)$ time, where $m$ is the query size, $|\Sigma|$ is the alphabet size, and the latter does so in $O(m+\log n)$ time, where $n$ is the text size. If one wants to output all appearances of the query, an additive cost of $O(occ)$ time is sufficient, where $occ$ is the size of the output. We propose a novel way of combining the two into, what we call, a {\em suffix tray}. The space and construction time remain linear and the query time improves to $O(m+\log|\Sigma|)$ for integer alphabets from a linear range, i.e. $\Sigma \subset \{1,\cdots, cn\}$, for an arbitrary constant $c$. The construction and query are deterministic. Here also an additive $O(occ)$ time is sufficient if one desires to output all appearances of the query. We also consider the online version of indexing, where the text arrives online, one character at a time, and indexing queries are answered in tandem. In this variant we create a cross between a suffix tree and a suffix list (a dynamic variant of suffix array) to be called a {\em suffix trist}; it supports queries in $O(m+\log|\Sigma|)$ time. The suffix trist also uses linear space. Furthermore, if there exists an online construction for a linear-space suffix tree such that the cost of adding a character is worst-case deterministic $f(n,|\Sigma|)$ ($n$ is the size of the current text), then one can further update the suffix trist in $O(f(n,|\Sigma|)+\log |\Sigma|)$ time. The best currently known worst-case deterministic bound for $f(n,|\Sigma|)$ is $O(\log n)$ time.
BibTeX
@article{cole2015suffix,
  author = {Richard Cole and Tsvi Kopelowitz and Moshe Lewenstein},
  title = {{Suffix Trays and Suffix Trists: Structures for Faster Text Indexing}},
  journal = {Algorithmica},
  year = {2015},
  doi = {10.1007/s00453-013-9860-6},
}

Loading related content...

Figure