class Naive extends PatternMatchingAlgorithm { void find(char t[], int n, char p[], int m) throws Exception { boolean trivial[] = new boolean[m]; int cnt = 0; clear_table(trivial, m); for (int i = 0; i + m <= n; i++) { pause(i, trivial, -1, false, false, cnt); for (int j = 0; j < m; j++) { if (stopRequested) return; cnt++; if (t[i+j] == p[j]) { pause(i, trivial, j, false, (j+1==m), cnt); } else { pause(i, trivial, j, true , false, cnt); break; } } } } }