We address the problem of approximate string matching in two dimensions, that is, to nd a pattern of size m m in a text of size n n with at most k errors (substitutions, insertions and deletions). Although the problem can be solved using dynamic programming in time O(m2 n2 ), this is in general too expensive for small k. So we design a ltering algorithm which avoids verifying most of the text with dynamic programming. This lter is based on a one-dimensional multi-pattern approximate search algorithm. The average complexity of our resulting algorithm is O(n2 klog m =m2 ) for k < m(m + 1)=(5log m), which is optimal and matches the best previous result which allows only substitutions. For higher error levels, we present an algorithm with time complexity O(n2 k=(wp )) (where w is the size in bits of the computer word and is the alphabet size). This algorithm works for k < m(m+1)(1?e=p ), where e = 2:718:::, a limit which is not possible to improve. These are the rst good expected-cas...
Ricardo A. Baeza-Yates, Gonzalo Navarro