I am unable to understand this part of the program for creating suffix array using n^2logn method
for(int cnt = 1, stp = 1; cnt < N; cnt *= 2, ++stp) {
for(int i = 0; i < N; ++i) {
L[i].firstHalf = suffixRank[stp - 1][i];
L[i].secondHalf = i + cnt < N ? suffixRank[stp - 1][i + cnt] : -1;
L[i].originalIndex = i;
}
I have found this implementation at http://e-maxx-eng.github.io/string/suffix-array.html and
http://discuss.codechef.com/questions/21385/a-tutorial-on-suffix-arrays?sort=votes&page=1
Can anybody explain with proper example?