The Pattern Matching problem with Swaps consists in finding all occurrences of a pattern P in a text T, when disjoint local swaps in the pattern are allowed. In the Approximate Pattern Matching problem with Swaps one seeks, for every text location with a swapped match of P, the number of swaps necessary to obtain a match at the location. In this paper we devise two general algorithms for both Standard and Approximate Pattern Matching with Swaps, named CROSS-SAMPLING and BACKWARD-CROSS-SAMPLING, with a and worst-case time complexity, respectively. Then we provide efficient implementations of them, based on bit-parallelism, which achieve and worst-case time complexity, with patterns whose length is comparable to the word-size of the target machine. From an extensive comparison with some of the most effective algorithms for the swap matching problem, it turns out that our algorithms are very flexible and achieve very good results inpractice.
['Matteo Campanelli', 'Domenico Cantone', 'Simone Faro', 'Emanuele Giaquinta']
PATTERN MATCHING WITH SWAPS IN PRACTICE