How to implement Suffix array in c

529 views Asked by At

However its easy to get the implementation using C++ as there is built-in Sort() function in algorithm header file.
I have gone through the both naive method and O(nlogn) methods of forming the array. In both the cases the sort() function is used for sorting the suffixes.

Is there any good method in C?

1

There are 1 answers

2
Rishi On

Are you saying you googled "sort c" and found NOTHING? I see several helpful links when I do that. For example, have a look at this question and its answers: C library function to do sort. Also the Wikipedia article on suffix arrays gives good overview of methods of constructing suffix arrays: O(N) method of constructing a suffix tree and then the suffix array, O(N^2 log N) method of sorting the suffixes (sorting requires O(N log N) comparisons, and each comparison is O(N), so the total time is O(N^2 log N)), and other advanced methods. The Wikipedia article also points to a few implementations in Java, C/C++ etc.