Strings 2008 2 3

From MDWiki
Revision as of 02:07, 10 January 2008 by ThomasHuber (talk | contribs)
Jump to navigationJump to search

Brute force (naive) search

The simplest, but also least efficient approach to text searching is to check whether the pattern matches the string at every possible position in the string. This is called the brute-force or naive string search algorithm. The procedure is illustrated below.

naive string search algorithm


If the text is n characters long and the pattern is m characters long, it takes O(n*m) steps.


--ThomasHuber 13:07, 10 January 2008 (EST)