Manuscript Offprint
arXiv:2610.39482Substring Complexity in BWT-Runs Bounded Space
Abstract
Given a string , its substring complexity is defined as , where is the number of its distinct substrings of length in . We show how to compute it in time, using only words of space, where denotes the number of runs in the Burrows-Wheeler transform.
1 Introduction
Given a string , its substring complexity is defined as , where is the number of its distinct substrings in of length . It is by now an accepted measure of the compressibility of a string , with many pleasant properties . Kociumaka et al. show that (and all 's) can be computed in time from the array of longest common prefix .
We show that can be computed in space and in time, where denotes the number of runs in the Burrows-Wheeler transform. Computing compressibility measures (such as ) in compressed space is an important subject, as it allows us to decide if a potentially very large text is compressible or not, without using space.
1.2 Our Contribution and Techniques
We show that can be computed in space and in time. The fact that [KP18] somehow hints at the possibility of such a result. Our algorithm relies on a relatively simple usage of irreducible LCP-values [KMP09]: they determine all other LCP-values in a regular manner, and there can be at most of them [Sir10] as they are at the beginnings of BWT-runs. The general approach is to first compute these irreducible LCP-values, which can be done in space and in time [SBS 26]. Together with their positions in the text, which can be computed in the same space, we show that any BWT-run induces at most 4 different ...
2 Preliminaries
Let be a string over an ordered alphabet of size . We assume that and is smaller than every other symbol. For , is the substring from position to , and is the -th suffix. For strings and , denotes the length of their longest common prefix. The suffix array is the permutation of with [MM93]. Its inverse is ISA, . The LCP array is defined by and for . The permuted LCP array PLCP [KMP09] lists the same values in text order: ( ). The Burrows-Wheeler transform of is the string with , where . A run in is a maximal substring of equal symbols. Let be the number of runs and their starting positions. Let
be the sampled text positions in text order (those are the positions stored in any move-data structure [BFN24]). The intervals defined by these positions cover , and make it particularly easy to compute certain PLCP-values, as for every and every we have [Sir10]:
This means that all we need to store are the PLCP-values PLCP[u_x]; these are called irreducible (the other ones are called reducible, as they can be computed by (1)).
For , of is the number of distinct substrings in ( ), and the substring complexity is defined as . Important for our algorithm is the computation of the 's through the (P)LCP-values [KNP23]:
This formula counts the contribution of every suffix to : any PLCP-value less than means that there is a suffix not sharing the first symbols with its lexicographic predecessor, and therefore accounts to .
3 Computation
We start from (2), which can also be written as
For what follows, look also at Fig. 1. Now take any interval , and let be the PLCP-value at its beginning. Let denote the length of and look at all suffixes starting in that interval, for : contributes 1 to for all , contributes 1 to for all , and so on, until contributes 1 to for all . This is because (1) gives for all , so the selection criterion in (3) is equivalent to:
Thus, looking at as a function of , we can say that every contributes 1 to a size- interval in . Those intervals are overlapping, forming an affine function:

Figure 1: On the top, the thicker gray line indicates the PLCP-values in the interval . The suffix has length , and the interval length . On the bottom, we can see to which in the respective PLCP-values contribute: each to a bar of length (depicted in thick gray lines). The trapezoid's height indicates the number of such bars stabbed by a position. Note that the figure just shows the case such that the bottom bar ends after the top bar starts; the other case is similar.
• up to , there is no t contributing,
• from and up to , there is one more contributing t per increasing k,
• from and up to , there is one more contributing t per k, but also one less, so the number of contributing t's stays the same,
• from and up to , there is one less contributing t,
• and after , there is again no t contributing.
This means that the entire function is the sum of affine functions whose slopes changes only at the extreme points where and can contribute to for all :
•
•
• , and
•
In particular, the maximum must be attained at one of those points.
To evaluate at these points, we first sort them -time sorting suffices), and insert them into an array of length , each with the value for the change of slopes: at and , the slope increases by , as it is either the beginning of a rise, or the end of a fall; whereas at and a “” indicates a slope decrease. We further contract by adding up all slopes at the same position, such that after that every position occurs at most once in . We can then scan from left to right, adding up the slope changes: We start with and slope at . When coming from and seeing for some , we first compute the new value , and then add the 'th slope value to . This allows us to keep track of the maximum ratio seen so far, hence computing .
References
[BCC 24] Ruben Becker, Matteo Canton, Davide Cenzato, Sung-Hwan Kim, Bojana Kodric, and Nicola Prezza. Sketching and streaming for dictionary compression. In Ali Bilgin, James E. Fowler, Joan Serra-Sagristà, Yan Ye, and James A. Storer, editors, Data Compression Conference, DCC 2024, Snowbird, UT, USA, March 19-22, 2024, pages 213–222. IEEE, 2024.
[BFGP23] Giulia Bernardini, Gabriele Fici, Paweł Gawrychowski, and Solon P. Pissis. Substring complexity in sublinear space. In Proc. 34th International Symposium on Algorithms and Computation (ISAAC), volume 283 of LIPIcs, pages 12:1–12:19. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2023.
[BFN24] Nico Bertram, Johannes Fischer, and Lukas Nalbach. Move-r: Optimizing the r-index. In Proc. 22nd International Symposium on Experimental Algorithms (SEA), volume 301 of LIPIcs, pages 1:1–1:19. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2024.
[BW94] Michael Burrows and David J. Wheeler. A block-sorting lossless data compression algorithm. Technical Report 124, Digital Equipment Corporation, Systems Research Center, 1994.
[CEK 21] Anders Roy Christiansen, Mikko Berggren Ettienne, Tomasz Kociumaka, Gonzalo Navarro, and Nicola Prezza. Optimal-time dictionary-compressed indexes. ACM Transactions on Algorithms, 17(1):8:1–8:39, 2021.
[KI22] Akiyoshi Kawamoto and Tomohiro I. Substring complexities on run-length compressed strings. In Proc. 29th International Symposium on String Processing and Information Retrieval (SPIRE), volume 13617 of LNCS, pages 132–143. Springer, 2022.
[KLA 01] Toru Kasai, Gunho Lee, Hiroki Arimura, Setsuo Arikawa, and Kunsoo Park. Linear-time longest-common-prefix computation in suffix arrays and its applications. In Proc. 12th Annual Symposium on Combinatorial Pattern Matching (CPM), volume 2089 of LNCS, pages 181–192. Springer, 2001.
[KMP09] Juha Kärkkäinen, Giovanni Manzini, and Simon J. Puglisi. Permuted longest-common-prefix array. In Proc. 20th Annual Symposium on Combinatorial Pattern Matching (CPM), volume 5577 of LNCS, pages 181–192. Springer, 2009.
[KN25] Gregory Kucherov and Yakov Nekrich. Online computation of normalized substring complexity. arXiv:2510.16454, 2025.
[KNP23] Tomasz Kociumaka, Gonzalo Navarro, and Nicola Prezza. Toward a definitive compressibility measure for repetitive sequences. IEEE Transactions on Information Theory, 69(4):2074–2092, 2023.
[KP18] Dominik Kempa and Nicola Prezza. At the roots of dictionary compression: String attractors. In Proc. 50th Annual ACM SIGACT Symposium on Theory of Computing (STOC), pages 827–840. ACM, 2018.
[MM93] Udi Manber and Gene Myers. Suffix arrays: A new method for on-line string searches. SIAM Journal on Computing, 22(5):935–948, 1993.
[Nav21] Gonzalo Navarro. Indexing highly repetitive string collections, part I: Repetitiveness measures. ACM Computing Surveys, 54(2):29:1–29:31, 2021.
[RRRS13] Sofya Raskhodnikova, Dana Ron, Ronitt Rubinfeld, and Adam D. Smith. Sublinear algorithms for approximating string compressibility. Algorithmica, 65(3):685–709, 2013.
[SBS 26] Ahsan Sanaullah, Nathaniel K. Brown, Pramesh Shakya, Arun Deegutla, Ardalan Naseri, Ben Langmead, Degui Zhi, and Shaojie Zhang. RLBWT-based LCP computation in compressed space for terabase-scale pangenome analysis. Bioinformatics, 42(Suppl. 1), 2026. Preprint: bioRxiv 10.64898/2026.01.23.701410.
[Sir10] Jouni Sirén. Sampled longest common prefix array. In Proc. 21st Annual Symposium on Combinatorial Pattern Matching (CPM), volume 6129 of LNCS, pages 227–237. Springer, 2010.