Hello everyone,
Is there an algorithm to build Suffix Array in complexity O(n)?
Thanks in advance!
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | maomao90 | 163 |
2 | Um_nik | 163 |
4 | atcoder_official | 161 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | nor | 153 |
9 | Dominater069 | 153 |
Hello everyone,
Is there an algorithm to build Suffix Array in complexity O(n)?
Thanks in advance!
Name |
---|
I don't know how to build it in O(n) but, Yes there are algorithms to build Suffix Arrays in O(n).
Li, Li & Huo (2016) gave the first in-place O(n) time suffix array construction algorithm that is optimal both in time and space, where in-place means that the algorithm only needs O(1) additional space beyond the input string and the output suffix array.
Li, Zhize; Li, Jian; Huo, Hongwei (2016). Optimal In-Place Suffix Sorting. Proceedings of the 25th International Symposium on String Processing and Information Retrieval (SPIRE). Lecture Notes in Computer Science. 11147. Springer. pp. 268–284. arXiv:1610.08305. doi:10.1007/978-3-030-00479-8_22. ISBN 978-3-030-00478-1.
source: https://en.wikipedia.org/wiki/Suffix_array
You can try to search dc3 algorithm (becareful that there are many wrong implementations)
You can build suffix trie in linear time by building SAM on the reversed string so I presume something similar should work for suffix array.
Note that SAM works in $$$O(26N)$$$ time, or more generally $$$O(\Sigma N)$$$ time where $$$\Sigma$$$ is the size of the alphabet. There are algorithms which run in $$$O(N)$$$ time even when $$$\Sigma = \Theta(N)$$$, such as DC3 and SAIS.