Manuscript Offprint
arXiv:2610.35543Tiny Suffix Arrays
Abstract
Suffix array and inverse suffix array queries on a text of length can be answered in time using an auxiliary data structure occupying words, for any .
1 Introduction
Let be a text over an ordered alphabet of size . Without loss of generality, we assume that the alphabet is and that is terminated by a unique sentinel character \(corresponding to 0), which is lexicographically smaller than all other characters. The suffix array (SA) of is a permutation of that lists the starting positions of all suffixes of in lexicographic order. The inverse suffix array (ISA) is the inverse permutation of SA, i.e., if and only if . For example, for , we have and . These fundamental data structures form the basis of numerous algorithms in string processing, data compression, bioinformatics, and full-text indexing [19, 24, 31].
Storing SA and ISA explicitly requires bits each, whereas the text itself can be represented in only bits. This difference is particularly significant for small alphabets (e.g., DNA sequences), where the space occupied by these structures can be substantially larger than that of the text. A major breakthrough in addressing this problem came with the introduction of the Compressed Suffix Array (CSA) [18] and the FM-index [12], which showed that SA and ISA queries can be supported in time using only bits, where hides polylogarithmic factors in . These foundational results initiated an extensive line of research, leading to several breakthroughs, including compressed suffix trees, entropy-compressed representations, and repetitiveness-aware representations [3, 11, 17, 15, 20, 22, 26, 21, 28, 27] of these fundamental data structures. Despite these remarkable advances, all such representations require bits in the worst case. In fact, this is an information-theoretic lower bound for representing either SA or ISA, since the text can be reconstructed from either permutation together with the frequency of each character. Thus, the space occupied by the text itself represents a fundamental barrier to space-efficient encodings of the SA and ISA. When the text is available, however, we can focus exclusively on the auxiliary space required to encode these arrays. This leads to the following natural problem:
Design a data structure within a prescribed space budget that efficiently supports SA and ISA queries, given read-only access to the underlying text.
Several related problems have been studied under a bounded auxiliary-space budget of words, for a tradeoff parameter . In particular, Bille et al. [6] showed that longest common extension (LCE) queries can be supported deterministically in time using words of auxiliary space. Subsequently, Bille et al. [5] improved the query time to while retaining the same space bound. Further results on LCE queries and their efficient construction were obtained by Tanimura et al. [29], Birenzwige et al. [7], and Kosolobov and Sivukhin [23]. Related results on sparse suffix-tree construction under small space constraints were obtained by Gawrychowski and Kociumaka [16] and Kosolobov and Sivukhin [23]. Meanwhile, significant progress has been made in text indexing under small auxiliary-space budgets. Bathie et al. [2] developed a data structure for internal pattern matching using words of auxiliary space, supporting queries in time. In a breakthrough result, Bibbens, Borevitz, and McCauley [4] developed a text index based on function inversion [13] that occupies words of auxiliary space and reports all occ occurrences of a pattern of length in time. Subsequently, Charalampopoulos et al. [8] improved the query time to while retaining the same space bound.
A step toward supporting SA and ISA queries in small auxiliary space was taken in recent work by Thankachan [30], where it was shown that SA, ISA, and several fundamental suffix-tree operations can be supported in polylogarithmic time using bits of auxiliary space, where is the alphabet size. However, this bound remains linear in up to an alphabet-dependent factor. To the best of our knowledge, no prior work establishes a general time-space tradeoff for supporting both SA and ISA queries using words of auxiliary space for an arbitrary parameter . We obtain the following result.
Theorem 1.1. Let be a text over an ordered alphabet of size , accessible through a read-only oracle supporting character access in constant time. For any integer , there exists an auxiliary data structure occupying words that supports both suffix array (SA) and inverse suffix array (ISA) queries in time.
Lemma 2.1. There exists an auxiliary data structure occupying space that, given two positions satisfying , reports all suffixes of lying strictly between and in lexicographic order in time.
Proof. We adapt existing techniques based on suffix sampling and range queries [1, 10]. First, we sample the suffixes and the corresponding prefixes at positions . For each sampled position , we construct a tuple , where is the lexicographic rank of among the sampled suffixes, and is the co-lexicographic rank of among the sampled prefixes. We maintain a two-dimensional orthogonal range reporting structure on the points , storing as satellite information. We use the linear-space data structure of Chazelle [9], which, for a set of points, occupies words and reports points in time, for any fixed constant . The total space usage is therefore words.
The original trade-off in [8] is words of space and query time for any . The bound we stated follows by substituting for , for a suitable constant .
Given a query , assume without loss of generality that , and let . For each , we issue a two-dimensional range reporting query to identify sampled positions satisfying (i) , and (ii) . Since , these conditions are equivalent to . The first condition defines a contiguous interval of co-lexicographic ranks, which can be obtained by binary searching for the reversed pattern among the reversed sampled prefixes. Each comparison takes character accesses. Similarly, the second condition defines a contiguous interval of lexicographic ranks, obtained by binary searching for and among the sampled suffixes. Here, instead of comparing suffixes character by character, we use LCE queries to determine their lexicographic order in time per comparison. Thus, both intervals can be computed in time. We report the points in their Cartesian product, outputting for each reported point. Each range reporting query takes time, where is its output size. Position 0 and the at most positions following the last sample are handled directly in time. Since every other position is reported for exactly one value of , the overall time is .
Lemma 2.2. There exists an auxiliary data structure occupying space that, given a pattern and a character range , reports all occurrences of (i.e., appended with ), for every , in time, where is the output size.
Proof. A straightforward approach is to maintain the pattern matching data structure of Charalampopoulos et al. [8], occupying space, and issue a separate pattern reporting query for , for each . However, this results in a total query time of . To achieve the claimed bound, we instead view as a string over the alphabet , replacing each character with followed by its binary representation of length . Let denote the resulting string, of length . We do not store explicitly, since any character of can be recovered from in time. We maintain the data structure of Charalampopoulos et al. [8] on , using the parameter , so that the auxiliary space remains .
Given a query , let be the encoding of under the same transformation. We partition into disjoint intervals, each consisting of characters whose binary representations share a common prefix . For each such interval, we issue a pattern reporting query for on . Since these intervals partition , the reported occurrences correspond precisely to those of for all , without duplication. The number of pattern reporting queries is thus reduced from to , while the transformed pattern lengths are . Substituting these parameters into the query bound yields the claimed time complexity.
3 The Data Structure
Depending on the value of , we consider two cases.
3.1 Solution for
In this case, our data structure consists only of the -word structure supporting LCE queries, together with at most words of additional working space.
To answer an SA[i] query, we need to identify the i-th lexicographically smallest suffix, for which we use known selection algorithms. Since the classical median-of-medians algorithm requires working space, we instead employ space-efficient selection algorithms as follows. We consider two subcases depending on the value of .
-
For , we use Frederickson's read-only selection algorithm [14], which requires comparisons and words of working space. This fits within our -word space bound. Since each comparison can be performed using an LCE query in time, the total query time is .
-
For , we instead use the constant-workspace selection algorithm of Munro and Raman [25], which performs comparisons for any fixed constant . Choosing , the resulting query time is .
To answer an ISA[j] query, we compare with all other suffixes and count those that are lexicographically smaller. This requires LCE queries and working space, resulting in a query time of , since .
3.2 Solution for
We first describe a scheme for sampling leaves of the suffix tree of [31]. Let denote the leaves in left-to-right order, where corresponds to the suffix . We initially sample the leaves , together with . For each initially sampled leaf whose suffix has length at least , we consider the subtree containing exactly those suffixes sharing its first characters, and additionally sample the leftmost and rightmost leaves of this subtree. No additional sampling is needed for suffixes shorter than . Clearly, the total number of sampled leaves is , and there are at most unsampled leaves between any two consecutive sampled leaves. The following lemma establishes a crucial property of this sampling scheme.
Lemma 3.1. If the suffixes corresponding to two consecutive sampled leaves have a longest common prefix (LCP) of length less than , then every unsampled suffix between them has a LCP of length less than with each of these two suffixes.
Proof. Suppose an intermediate suffix shares a prefix of length at least with either endpoint. Since the endpoints have a LCP of length less than , the corresponding length- prefix interval must have a boundary strictly between them. This boundary leaf would have been sampled, contradicting their consecutiveness.
Our auxiliary data structure consists of the following components: the structures of Lemmas 2.1 and 2.2, the -word data structure of Bille et al. [5] supporting LCE queries in time, and a sampled suffix array (SSA). The SSA stores a list of pairs , sorted by , one for each sampled leaf selected by the sampling scheme described above. Since the number of sampled leaves is , the SSA occupies words. Additionally, we reserve words of working space, bringing the total space to words. This remains since .
3.2.1 Decoding SA[i]
Given a query index , we binary search the SSA to check whether is sampled. If so, we return the stored value SA[i]. Otherwise, we identify two consecutive sampled leaves and such that , and retrieve SA[p] and SA[q] from the SSA. This takes time. We now show how to decode the subarray SA[p+1..q-1], from which SA[i] can be directly retrieved. To this end, we compute in time and consider the following two cases.
-
We first consider the case where . We invoke Lemma 2.1 to report and store all suffixes lying strictly between and . These correspond precisely to the entries of , possibly in a different order. Since there are such suffixes, the reporting takes time and words of working space. We then sort the reported suffixes using comparisons, each performed via an LCE query followed by a character comparison in time. Thus, the entire subarray can be decoded in time.
-
We next consider the case where . Let and . By Lemma 3.1, every suffix strictly between and has a longest common prefix with each endpoint of length in . We exploit this property to identify these suffixes using pattern reporting queries. Specifically, for each , we consider the prefix and issue a query using Lemma 2.2 for all patterns with . Similarly, we consider and query all patterns with . We restrict the queries at to characters strictly between and , avoiding overlaps. These queries report precisely the suffixes lying strictly between and , since every such suffix must differ from both endpoints within the first characters.
There are queries, with pattern lengths at most . By Lemma 2.2, their total running time for these queries is , since . We store the reported suffix positions using words of working space and sort them using LCE-based comparisons, taking additional time. Thus, the subarray , and hence , can be obtained in time.
Combining both cases, we obtain a query time of .
3.2.2 Decoding ISA[j]
Given a query position , we binary search the SSA, using LCE queries to compare with the sampled suffixes and determine its lexicographic position among them. If is itself sampled, we directly return its stored rank ISA[j]. Otherwise, we identify two consecutive sampled leaves and such that lexicographically. This takes time. We then decode the subarray using the algorithm described in the previous subsection and locate within it to obtain ISA[j]. Thus, ISA queries take time.
4 Concluding Remarks
We establish space-time trade-offs for suffix array and inverse suffix array queries under a bounded auxiliary-space budget. Together with existing results on LCE queries [5], this shows that three of the most fundamental primitives in string algorithms can be supported using sublinear auxiliary space. Since suffix arrays form the basis of numerous string data structures and algorithms (beyond exact pattern matching), our result opens up opportunities for exploring new space-time trade-offs across a broad range of string processing problems.
Acknowledgments. This research was supported in part by U.S. National Science Foundation (NSF) Awards CCF-2316691 and CCF-2315822. Many thanks to the authors of [8] for sharing their preprint and to Solon Pissis for helpful suggestions.
Use of Generative AI All original ideas, including the main results and proof techniques, were developed by the authors. OpenAI's ChatGPT was used to identify relevant literature, improve exposition, and review technical arguments. The authors take full responsibility for the correctness and content of the paper.
References
[1] L. A. K. Ayad, G. Loukides, and S. P. Pissis. Text indexing for long patterns using locally consistent anchors. VLDB J., 34(5):58, 2025.
[2] G. Bathie, P. Charalampopoulos, and T. Starikovskaya. Internal pattern matching in small space and applications. In 35th Annual Symposium on Combinatorial Pattern Matching, CPM 2024, Japan, 2024, volume 296 of LIPIcs, pages 4:1–4:20. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2024.
[3] D. Belazzougui and G. Navarro. Alphabet-independent compressed text indexing. ACM Trans. Algorithms, 10(4):23:1–23:19, 2014.
[4] J. Bibbens, L. Borevitz, and S. McCauley. Space-efficient text indexing with mismatches using function inversion. In Proceedings of the 58th Annual ACM Symposium on Theory of Computing, STOC 2026, USA, 2026, pages 1061–1072. ACM, 2026.
[5] P. Bille, I. L. Gørtz, M. B. T. Knudsen, M. Lewenstein, and H. W. Vildhøj. Longest common extensions in sublinear space. In F. Cicalese, E. Porat, and U. Vaccaro, editors, Combinatorial Pattern Matching - 26th Annual Symposium, CPM 2015, Italy, June 29 - July 1, 2015, Proceedings, volume 9133 of Lecture Notes in Computer Science, pages 65–76. Springer, 2015.
[6] P. Bille, I. L. Gørtz, B. Sach, and H. W. Vildhøj. Time-space trade-offs for longest common extensions. Journal of Discrete Algorithms, 25:42–50, 2014.
[7] O. Birenzwige, S. Golan, and E. Porat. Locally consistent parsing for text indexing in small space. SIAM J. Comput., 54(4):916–963, 2025.
[8] P. Charalampopoulos, T. E. Ghazi, J. Ellert, and T. Starikovskaya. Improved time-space tradeoffs for exact and approximate text indexing. In Proceedings of the 2027 ACM-SIAM Symposium on Discrete Algorithms (SODA), 2027. To appear.
[9] B. Chazelle. A functional approach to data structures and its use in multidimensional searching. SIAM J. Comput., 17(3):427–462, 1988.
[10] Y. Chien, W. Hon, R. Shah, S. V. Thankachan, and J. S. Vitter. Geometric BWT: Compressed text indexing via sparse suffixes and range searching. Algorithmica, 71(2):258–278, 2015.
[11] P. Ferragina and G. Manzini. Compression boosting in optimal linear time using the Burrows-Wheeler Transform. In J. I. Munro, editor, Proceedings of the Fifteenth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2004, USA, 2004, pages 655–663. SIAM, 2004.
[12] P. Ferragina and G. Manzini. Indexing compressed text. J. ACM, 52(4):552–581, 2005.
[13] A. Fiat and M. Naor. Rigorous time/space trade-offs for inverting functions. SIAM J. Comput., 29(3):790–803, 1999.
[14] G. N. Frederickson. Upper bounds for time-space trade-offs in sorting and selection. J. Comput. Syst. Sci., 34(1):19–26, 1987.
[15] T. Gagie, G. Navarro, and N. Prezza. Fully functional suffix trees and optimal text searching in BWT-runs bounded space. J. ACM, 67(1):2:1–2:54, 2020.
[16] P. Gawrychowski and T. Kociumaka. Sparse suffix tree construction in optimal time and space. In P. N. Klein, editor, Proceedings of the Twenty-Eighth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2017, Barcelona, Spain, pages 425–439. SIAM, 2017.
[17] R. Grossi, A. Gupta, and J. S. Vitter. High-order entropy-compressed text indexes. In Proceedings of the Fourteenth Annual ACM-SIAM Symposium on Discrete Algorithms, January 12-14, 2003, Baltimore, Maryland, USA, pages 841–850. ACM/SIAM, 2003.
[18] R. Grossi and J. S. Vitter. Compressed suffix arrays and suffix trees with applications to text indexing and string matching. SIAM J. Comput., 35(2):378–407, 2005.
[19] D. Gusfield. Algorithms on Strings, Trees, and Sequences: Computer Science and Computational Biology. Cambridge University Press, Cambridge, UK, 1997.
[20] D. Kempa and T. Kociumaka. Collapsing the hierarchy of compressed data structures: Suffix arrays in optimal compressed space. In 64th IEEE Annual Symposium on Foundations of Computer Science, FOCS 2023, USA, November 6-9, 2023, pages 1877–1886. IEEE, 2023.
[21] D. Kempa and T. Kociumaka. Constant-time inverse suffix array queries in compact space and sublinear-time construction of suffix array indexes. CoRR, abs/2608.19123, 2026.
[22] D. Kempa and T. Kociumaka. Tight lower bounds for central string queries in compressed space. In K. G. Larsen and B. Saha, editors, Proceedings of the 2026 Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2026, Canada, 2026, pages 1824–1840. SIAM, 2026.
[23] D. Kosolobov and N. Sivukhin. Construction of sparse suffix trees and LCE indexes in optimal time and space. In S. Inenaga and S. J. Puglisi, editors, 35th Annual Symposium on Combinatorial Pattern Matching, CPM 2024, Fukuoka, Japan, June 25-27, 2024, volume 296 of LIPIcs, pages 20:1–20:18. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2024.
[24] U. Manber and E. W. Myers. Suffix arrays: A new method for on-line string searches. SIAM J. Comput., 22(5):935–948, 1993.
[25] J. I. Munro and V. Raman. Selection from read-only memory and sorting with minimum data movement. Theor. Comput. Sci., 165(2):311–323, 1996.
[26] G. Navarro. Indexing highly repetitive string collections, part II: compressed indexes. ACM Comput. Surv., 54(2):26:1–26:32, 2022.
[27] L. M. Russo, G. Navarro, and A. L. Oliveira. Fully-compressed suffix trees. In LATIN 2008: Theoretical Informatics: 8th Latin American Symposium, Búzios, Brazil, April 7-11, 2008. Proceedings 8, pages 362–373. Springer, 2008.
[28] K. Sadakane. Compressed suffix trees with full functionality. Theory Comput. Syst., 41(4):589–607, 2007.
[29] Y. Tanimura, T. I, H. Bannai, S. Inenaga, S. J. Puglisi, and M. Takeda. Deterministic sublinear space LCE data structures with efficient construction. In 27th Annual Symposium on Combinatorial Pattern Matching, CPM 2016, Israel, 2016, volume 54 of LIPIcs, pages 1:1–1:10. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2016.
[30] S. V. Thankachan. Compressed inverse suffix arrays. CoRR, abs/2607.17287, 2026.
[31] P. Weiner. Linear pattern matching algorithms. In 14th Annual Symposium on Switching and Automata Theory, USA, October 15-17, 1973, pages 1–11. IEEE Computer Society, 1973.