| Variations: |
- there are many suffix array construction algorithms, from the trivial \(O(n^2\log n)\) to optimal \(O(n)\); this visualization shows seven:
- Manber–Myers prefix doubling, \(O(n\log n)\)
- Larsson–Sadakane, the same doubling that sorts only the suffixes that still tie and skips the finished ones, also \(O(n\log n)\) but much faster in practice
- Kärkkäinen–Sanders (DC3), \(O(n)\), which sorts the suffixes at positions not divisible by 3 recursively, as the suffixes of a text of triple names about two thirds as long, sorts the rest by one radix sort with their help, and merges the two
- Seward's copy, the suffix sorting of bzip2, which groups the suffixes by their first two characters, sorts a few of the groups directly and copies the order of every finished bucket into the groups it determines, fast in practice but \(O(n^2\log n)\) in the worst case
- Itoh–Tanaka, which sorts only the suffixes whose first character is at most the second, by plain comparison, and induces the rest from them in one pass, fast in practice but \(O(n^2\log n)\) in the worst case
- Ko–Aluru, \(O(n)\), which sorts only the suffixes of the less common type, ↘ or ↗, and induces the rest from them in one pass
- SA-IS, its successor, also \(O(n)\), which sorts only the suffixes starting in valleys, at most half of them, and induces the order of all the others from them
- the array can be used with or without the LCP array; the trade-off is more space against faster operations
|