3 int naive3( int textrow
, int textcolumn
, int patternrow
, int patterncolumn
)
7 for(i
= textcolumn
; i
< patterncolumn
; i
++) {
11 for(j
= 0; j
< m
; j
++) {
13 if( pattern
[patternrow
][j
] == text
[textrow
][k
])
27 /* No match found on this row */
33 /* x and y can be -1 */
36 unsigned int i
, row
, matches
= 0;
39 for ( row
= 0; row
< n
- m
+ 1; row
++ ) {
43 /* Iterate through results on the same row */
46 x
= naive3( row
, x
, 0, n
- m
);
48 /* If a row is found, check the m - 1 rows underneath it for matches */
51 for ( i
= 1; i
< m
; i
++) {
52 /* Optimization: instead of checking against n chars on
53 subsequent rows, just check against the next m chars after x */
54 y
= naive3( row
+ i
, x
, i
, x
+ m
);
59 /* If we reached to the final line above x without breaking, we have a match */
63 /* After each attempt,increase the counter + 1 */