Algorithms and Data Structures · Senior · Question 44 of 75

What is the time complexity of building a suffix array naively by sorting all suffixes?

Explanation

There are n suffixes and n log n comparisons, each of which may read O(n) characters. Prefix doubling brings it to O(n log n), and SA-IS to O(n). Suffix arrays answer substring queries with binary search.

Further reading

Problem with a question

Algorithms and Data Structures · Senior · question 44

Test yourself

Take the Algorithms and Data Structures · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz