A suffix arraySA is the list of indices sorting all suffixes of S lexicographically; with LCP it powers fast substring and repetition queries.
2. The Problem It Solves
Answer “how do suffixes relate?” in sorted order — used for substring search, longest repeated substring, number of distinct substrings, and BWT-adjacent structures.
3. The Core Idea
Doubling: sort suffixes by their first 2^k characters using ranks from the previous 2^{k-1} sort — like radix sort on pairs (rank[i], rank[i+2^{k-1}]).
4. How It Works (Table)
Step
What Happens
1
Pad with sentinel $ smaller than alphabet if needed.
2
Initial ranks = character codes.
3
Repeat: sort SA by pairs (rank[i], rank[i+k]) until ranks unique.
4
Result SA is lexicographic suffix order.
5. Dry Run Example
"aba
quot; → suffixes aba$, ba$, a$, $ → sorted order indices give SA.