## Abstract

Let a text string T of n symbols and a pattern string P of m symbols from alphabet Σ 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′_{ℓ} ← p_{ℓ+1} and p′_{ℓ+1} ← p_{ℓ}), 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(n√m log m) for a general alphabet Σ. 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 σ), where σ = min(m,|Σ|). Consequently, the total time for solving the approximate pattern matching with swaps problem is O(f (n, m) + n log m log σ), where f(n, m) is the time necessary for solving the Pattern Matching with Swaps problem. Since f(n, m) was shown to be O(n log m log σ) this means our algorithm's running time is O(n log m log σ).

Original language | English |
---|---|

Pages (from-to) | 33-39 |

Number of pages | 7 |

Journal | Information Processing Letters |

Volume | 83 |

Issue number | 1 |

DOIs | |

State | Published - 16 Jul 2002 |

### Bibliographical note

Funding Information:*Corresponding author. Partially supported by NSF grant CCR-01-04494, ISF grant 282/01, and a BIU internal research grant. E-mail addresses: [email protected] (A. Amir), [email protected] (M. Lewenstein), [email protected] (E. Porat).

Funding Information:

1Partially supported by the Israel Ministry of Science Eshkol Fellowship 061-1-97. Part of this work was done while the author was visiting the Courant Institute at NYU.

### Funding

*Corresponding author. Partially supported by NSF grant CCR-01-04494, ISF grant 282/01, and a BIU internal research grant. E-mail addresses: [email protected] (A. Amir), [email protected] (M. Lewenstein), [email protected] (E. Porat). 1Partially supported by the Israel Ministry of Science Eshkol Fellowship 061-1-97. Part of this work was done while the author was visiting the Courant Institute at NYU.

Funders | Funder number |
---|---|

Israel Ministry of Science Eshkol Fellowship | 061-1-97 |

National Science Foundation | CCR-01-04494 |

Israel Science Foundation | 282/01 |

## Keywords

- Approximate pattern matching
- Combinatorial algorithms on words
- Design and analysis of algorithms
- Non-standard pattern matching
- Pattern matching
- Pattern matching with swaps