Approximate swapped matching
Let a text string T of n symbols and a pattern string P of m symbols from alphabet E be given. A swapped version P' of P is a length m string derived from P by a series of local swaps (i.e., p(l)' <-- p(l+1) and p(l+1)' <-- p(l)), where each element can participate in no more than one swap. The Pattern Matching with Swaps problem is that of finding all locations i of T for which there exists a swapped version P' of P with an exact matching of P' in location i of T. Recently, some efficient algorithms were developed for this problem. Their time complexity is better than the best known algorithms for pattern matching with mismatches. However, the Approximate Pattern Matching with Swaps problem was not known to be solved faster than the Pattern Matching with Mismatches problem. In the Approximate Pattern Matching with Swaps problem the output is, for every text location i where there is a swapped match of P, the number of swaps necessary to create the swapped version that matches location i. The fastest known method to-date is that of counting mismatches and dividing by two. The time complexity of this method is O(nrootm log m) for a general alphabet Sigma. In this paper we show an algorithm that counts the number of swaps at every location where there is a swapped matching in time O (n log m log sigma), where sigma = min(m, \Sigma\). Consequently, the total time for solving the approximate pattern matching with swaps problem is O(f (n, m) + n log m log sigma), where f (n, in) is the time necessary for solving the Pattern Matching with Swaps problem. Since f (n, in) was shown to be O(n log m log a) this means our algorithm's running time is O(n log m log Q). (C) 2001 Elsevier Science B.V. All rights reserved.
pattern matching pattern matching with swaps approximate pattern matching design and analysis of algorithms combinatorial algorithms on words non-standard pattern matching