Can anyone point to best algorithm for substring search in another string? or search for a char array in another char array?
+8
A:
The best from what point of view? Knuth-Morris-Pratt is a good one. You can find more of them discussed on the Wikipedia entry for string searching algorithms.
Mehrdad Afshari
2009-08-11 15:21:58
+3
A:
It depends on what types of searching you are doing. Specific substring over a specific string? Specific substring over many different strings? Many different substrings over a specific string?
Here's a popular algorithm for a specific substring over many different strings.
John Calsbeek
2009-08-11 15:23:09
It is strstr.c for alpha. Which algorithm it uses? Which algorithm is used in x86 (or _64) for strstr?
osgx
2010-03-03 08:55:45
A:
Boyer-Moore algorithm: http://en.wikipedia.org/wiki/Boyer–Moore_string_search_algorithm
RBarryYoung
2009-08-11 17:52:50