Pattern matching with swaps

Amihood Amir, Yonatan Aumann, Gad M. Landau, Moshe Lewenstein, Noa Lewenstein

Research output: Contribution to journalConference articlepeer-review


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′l←tl+1 and t′l+1←tl) 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 where there is 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(mn) time. In this paper we show the first algorithm that solves the pattern matching with swaps problem in time o(mn). We present an algorithm whose time complexity is O(nm1/3 log m log2 σ) for a general alphabet Σ, where σ = min(m, |Σ|).

Original languageEnglish
Pages (from-to)144-153
Number of pages10
JournalAnnual Symposium on Foundations of Computer Science - Proceedings
StatePublished - 1997
Externally publishedYes
EventProceedings of the 1997 38th IEEE Annual Symposium on Foundations of Computer Science - Miami Beach, FL, USA
Duration: 20 Oct 199722 Oct 1997

Bibliographical note

Funding 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.

ASJC Scopus subject areas

  • Hardware and Architecture


Dive into the research topics of 'Pattern matching with swaps'. Together they form a unique fingerprint.

Cite this