String matching
Input
Text: = 0 1 1 Pattern: = 0 1 1
Objective
Find all occurrences of in as substring
Knuth-Morris-Pratt: +
and if the alphabet contains wildcards? Clifford et al. approach: use finite field as alphabet
Algorithm
Encode input as finite field elements Set up systems of equations for mismatch positions For = 0 to do Compute =
=1
Find roots of End for Encode input as integers Verify that all mismatches are found for each position
Preliminary 1: Convolutions
Fourier Transform
= = 1
Polynomial multiplication
Convolutions
=0
Preliminary 2: 2 trick
1
1 1 1 2 1 1
2 1 1
+ + +
2 2 2 2 2 2
2 + 2 2
1
+ + + +
+ + +
= = =
2 +
0 1 2 = 2
=
=0
+ + +
1 1 1 2 1 1
2 1 1
+ + +
2 2 2 2 2 2
2 + 2 2
+ + + +
+ + +
= = =
2 +
=1
0 1 2 = 2
1
Verification step
For each position :
=0
2 ? + + =
=1
Analysis
Running time: log 2 log 2 + log log Optimal: