I am reading about KMP for string matching. It needs a preprocessing of the pattern by building a prefix table. For example for the string ababaca
KMP
ababaca
string text = "ababbabbababbababbabb"; static int arr[30];
int i = 1; while (i < text.length()) { int j = 0; int value = 0; while (((i + j) < text.length()) && (text[j] == text[i + j])) val[i + j] = ++value, j++; i += j + 1; }
required output stored in val[]