Jump to content

Two-dimensional pattern matching

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by AmirOnWiki (talk | contribs) at 10:17, 28 June 2025 (starting an article). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computer science, two-dimensional pattern matching is the problem of locating occurrences of a two-dimensional matrix of characters ("the pattern") in a bigger two-dimensional matrix ("the picture", or, in analogy with string searching, "the text").

The naïve solution

Assume given a pattern and a picture , where . The simplest approach is to compare P against every sub-array of size </math>m\times m</math> in T. This algorithm has a worst-case time of . It is usually assume that math>m\le n/2</math>, whence this can be written as math>\Theta(n^2m^2)</math>.