Efficient special cases of pattern matching with swaps

  • Amihood Amir
  • Gad M. Landau
  • Moshe Lewenstein
  • Noa Lewensteint
Session V
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1448)


Let a text string 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 where there is an exact matching of P in location i of T′.

It was recently shown that the Pattern Matching with Swaps problem has a solution in time O(nm1/3 log m log2 σ), where σ = min(|Σ|, m). We consider some interesting special cases of patterns, namely, patterns where there is no length-one run, i.e. there are no a, b, c ∈ Σ where b # a and b # c and where the substring abc appears in the pattern. We show that for such patterns the pattern matching with swaps problem can be solved in time O(n log2m).

Key Words

Design and analysis of algorithms combinatorial algorithms on words pattern matching pattern matching with swaps approximate pattern matching generalized pattern matching 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    K. Abrahamson. Generalized string matching. SIAM J. Computing, 16(6):1039–1051, 1987.Google Scholar
  2. 2.
    A. Amir, Y. Aumann, G. Landau, M. Lewenstein, and N. Lewenstein.Pattern matching with swaps. Proc. 38th IEEE FOCS, pages 144–153, 1997.Google Scholar
  3. 3.
    A. Amir and M. Farach. Efficient 2-dimensional approximate matching of halfrectangular figures. Information and Computation, 118(1):1–11, April 1995.Google Scholar
  4. 4.
    R.S. Boyer and J.S. Moore. A fast string searching algorithm. Comm. ACM, 20:762–772, 1977.Google Scholar
  5. 5.
    M.J. Fischer and M.S. Paterson. String matching and other products. Complexity of Computation, R.M. Karp (editor), SIAM-AMS Proceedings, 7:113–125, 1974.Google Scholar
  6. 6.
    R. Karp, R. Miller, and A. Rosenberg. Rapid identification of repeated patterns in strings, arrays and trees. Symposium on the Theory of Computing, 4:125–136, 1972.Google Scholar
  7. 7.
    D.E. Knuth, J.H. Morris, and V.R. Pratt. Fast pattern matching in strings. SIAM J. Computing, 6:323–350, 1977.Google Scholar
  8. 8.
    S. Rao Kosaraju. Efficient string matching. Manuscript, 1987.Google Scholar
  9. 9.
    V. I. Levenshtein. Binary codes capable of correcting, deletions, insertions and reversals. Soviet Phys. Dokl., 10:707–710, 1966.Google Scholar
  10. 10.
    R. Lowrance and R. A. Wagner. An extension of the string-to-string correction problem. J. of the ACM, pages 177–183, 1975.Google Scholar
  11. 11.
    S. Muthukrishnan and H. Ramesh. String matching under a general matching relation. Information and Computation, 122(1):140–148, 1995.Google Scholar
  12. 12.
    A. Pentland. Invited talk. NSF Institutional Infrastructure Workshop, 1992.Google Scholar
  13. 13.
    R. Y. Pinter. Efficient string matching with don't care patterns. In Z. Galil A. Apostolico, editor, Combinatorial Algorithms on Words, volume 12, pages 11–29. NATO ASI Series F, 1985.Google Scholar
  14. 14.
    P. Weiner. Linear pattern matching algorithm. Proc. 14 IEEE Symposium on Switching and Automata Theory, pages 1–11, 1973.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1998

Authors and Affiliations

  • Amihood Amir
    • 1
    • 2
  • Gad M. Landau
    • 3
  • Moshe Lewenstein
    • 4
  • Noa Lewensteint
    • 5
  1. 1.Georgia Institute of TechnologyCollege of ComputingAtlanta
  2. 2.Bar-Ilan UniversityRamat-GanIsrael
  3. 3.Department of Computer ScienceHaifa UniversityHaifaIsrael
  4. 4.Department of Mathematics and Computer ScienceBar-Ilan UniversityRamat-GanIsrael
  5. 5.Department of Mathematics and Computer ScienceBar-Ilan UniversityRamat-GanIsrael

Personalised recommendations