Let a text string T of n symbols and a pattern string P of m symbols from alphabet Σ be given. A swapped version T′ of T is a length n string derived from T by a series of local swaps (i.e., t′ℓ ← tℓ+1 and t′ℓ+1 ← tℓ), where each element can participate in no more than one swap. The pattern matching with swaps problem is that of finding all locations i for which there exists a swapped version T′ of T with an exact matching of P in location i of T′. It has been an open problem whether swapped matching can be done in less than O(nm) time. In this paper we show the first algorithm that solves the pattern matching with swaps problem in time o(nm). We present an algorithm whose time complexity is O(nm1/3 log m log σ) for a general alphabet Σ, where σ = min(m, |Σ|).
Bibliographical noteFunding Information:
1A preliminary version of this paper appeared in FOCS 97. 2Partially supported by NSF grant CCR-96-10170, BSF grant 96-00509, and a BIU internal research grant. 3Partially supported by NSF grants CCR-9305873 and CCR-9610238 and by the Israel Science Foundation founded by the Israeli Academy of Sciences and Humanities. 4Partially supported by the Israel Ministry of Science and Arts Grant 8560.
- Combinatorial algorithms on words
- Design and analysis of algorithms
- Nonstandard pattern matching
- Pattern matching
- Pattern matching with swaps
ASJC Scopus subject areas
- Control and Optimization
- Computational Mathematics
- Computational Theory and Mathematics