Skip to main content

Fast algorithms for two dimensional and multiple pattern matching

  • Conference paper
  • First Online:

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 447))

Abstract

A new algorithm for searching a two dimensional m × m pattern in a two dimensional n × n text is presented. It performs on the average less comparisons than the size of the text: n 2/m using m 2 extra space. It improves on previous results in both time: n 2 and space: n or m 2, and is nearly optimal. Basically, it uses multiple string matching on only n/m rows of the text. We also present a new multi-string searching algorithm based in the Boyer-Moore string searching algorithm. A theoretical analysis is performed relying on original methods, word enumeration and probability theory, quite new in this field, and powerful. The average number of comparisons is proved to be asymptotically αn 2/m, α<1.

Preliminary version

This is a preview of subscription content, log in via an institution.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. A.V. Aho and M. Corasick. Efficient string matching: An aid to bibliographic search. C.ACM, 18(6):333–340, June 1975.

    Article  Google Scholar 

  2. A. Amir and M. Farach. The whole is faster than its parts: Efficient matching of non-rectangular shapes. Technical Report CS-TR-2256, Dept. of Computer Science, Univ. of Maryland, 1989.

    Google Scholar 

  3. T. Baker. A technique for extending rapid exact string matching to arrays of more than one dimension. SIAM J on Computing, 7:533–541, 1978.

    Article  Google Scholar 

  4. R. Bird. Two dimensional pattern matching. Inf. Proc. Letters, 6:168–170, 1977.

    Article  Google Scholar 

  5. R. Boyer and S. Moore. A fast string searching algorithm. C.ACM, 20:762–772, 1977.

    Article  Google Scholar 

  6. R.A. Baeza-Yates. Efficient Text Searching. PhD thesis, Dept. of Computer Science, University of Waterloo, May 1989. Also as Research Report CS-89-17.

    Google Scholar 

  7. R.A. Baeza-Yates. String searching algorithms revisited. In F. Dehne, J.-R. Sack, and N. Santoro, editors, Workshop in Algorithms and Data Structures, pages 75–96, Ottawa, Canada, August 1989. Springer Verlag Lecture Notes on Computer Science 382.

    Google Scholar 

  8. R. Baeza-Yates, G. Gonnet, and M. Regnier. Analysis of Boyer-Moore-type string searching algorithms. In 1st ACM-SIAM Symposium on Discrete Algorithms, pages 328–343, San Francisco, January 1990.

    Google Scholar 

  9. B. Commentz-Walter. A string matching algorithm fast on the average. In ICALP, volume 6 of Lecture Notes in Computer Science, pages 118–132. Springer-Verlag, 1979.

    Google Scholar 

  10. W. Feller. An Introduction to Probability Theory and Its Applications, volume 1. John Wiley and Sons, New York, 1968.

    Google Scholar 

  11. G.H. Gonnet. Efficient searching of text and pictures (extended abstract). Technical Report OED-88-02, Centre for the New OED., University of Waterloo, 1988.

    Google Scholar 

  12. R. N. Horspool. Practical fast searching in strings. Software — Practice and Experience, 10:501–506, 1980.

    Google Scholar 

  13. D.E. Knuth, J. Morris, and V. Pratt. Fast pattern matching in strings. SIAM J on Computing, 6:323–350, 1977.

    Google Scholar 

  14. R. Karp and M. Rabin. Efficient randomized pattern-matching algorithms. IBM J Res. Development, 31:249–260, 1987.

    Google Scholar 

  15. M. Regnier. Knuth-Morris-Pratt algorithm: An analysis. In MFCS'89, Lecture Notes in Computer Science 379, pages 431–444, Porabka, Poland, August 1989. Springer-Verlag. Also as INRIA Report 966, 1989.

    Google Scholar 

  16. W. Rytter. A correct preprocessing algorithm for Boyer-Moore string-searching. SIAM J on Computing, 9:509–512, 1980.

    Google Scholar 

  17. R.K. Shyamasundar. A simple string matching algorithm. Technical report, Nat. Centre for Software Development and Computing Techniques, Tata Institute of Fundamental Research, Bombay, India, 1976.

    Google Scholar 

  18. M.A. Sridhar. Efficient algorithms for multiple pattern matching. Technical Report Computer Sciences 661, University of Wisconsin-Madison, 1986.

    Google Scholar 

  19. A.C. Yao. The complexity of pattern matching for a random string. SIAM J on Computing, 8:368–387, 1979.

    Google Scholar 

  20. R.F. Zhu and T. Takaoka. A technique for two-dimensional pattern matching. Communications of the ACM, 32(9):1110–1120, September 1989.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

John R. Gilbert Rolf Karlsson

Rights and permissions

Reprints and permissions

Copyright information

© 1990 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Baeza-Yates, R., Régnier, M. (1990). Fast algorithms for two dimensional and multiple pattern matching. In: Gilbert, J.R., Karlsson, R. (eds) SWAT 90. SWAT 1990. Lecture Notes in Computer Science, vol 447. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-52846-6_102

Download citation

  • DOI: https://doi.org/10.1007/3-540-52846-6_102

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-52846-3

  • Online ISBN: 978-3-540-47164-6

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics