Question about construction of suffix array

Revision en1, by Azret, 2016-04-01 09:55:55


Reading the article from e-maxx (ALERT! RUSSIAN!). A piece of code ("radix sort of equivalence classes" part):

	for (int i=0; i<n; ++i) {
		pn[i] = p[i] - (1<<h);
		if (pn[i] < 0)  pn[i] += n;
	memset (cnt, 0, classes * sizeof(int));
	for (int i=0; i<n; ++i)
	for (int i=1; i<classes; ++i)
		cnt[i] += cnt[i-1];
	for (int i=n-1; i>=0; --i)
		p[--cnt[c[pn[i]]]] = pn[i];

Why p[] contains correct order of cyclic shifts of length 2k after?

Tags suffix, array, question, alert russian, construction


  Rev. Lang. By When Δ Comment
en1 English Azret 2016-04-01 09:55:55 585 Initial revision for English translation
ru2 Russian Azret 2016-04-01 08:17:33 40
ru1 Russian Azret 2016-04-01 08:15:54 551 Первая редакция (опубликовано)