Search code examples
algorithmsearchmatrixlanguage-agnosticknuth-morris-pratt

Efficient way to search a 2d matrix for another matrix of smaller size


I know KMP (Knuth–Morris–Pratt) is used for one dimensional search. Can it be applied on 2 dimensional array of data? Or is there a more advanced one?


Solution

  • Maybe you can find something in this question. You should be able to use KMP with some adaption if you flatten the matrices you are looking for.