3 ms·
This depends completely on your needle and your haystack. If it's the string "ABC" in "QABC" then certainly the naive algorithm will be the fastest. "Mechanica
by dalke 12y ago
This depends completely on your needle and your haystack. If it's the string "ABC" in "QABC" then certainly the naive algorithm will be the fastest.
"Mechanical sympathy" unfortunately is easily misinterpreted to mean to only listen to the machine. Remember though that Martin Thompson is alluding to Jackie Stewart and Formula One racing. All of the cars competed on the same track. But you wouldn't enter a Formula One car for the Baja 1000.
In fact, I don't think you should use term unless you have a specific goal in mind. KMP is only best for certain classes of searches. Boyer-Moore is used for others. And there are plenty of other algorithms with there own pros and cons. See http://www-igm.univ-mlv.fr/~lecroq/string/index.html http://www-igm.univ-mlv.fr/~lecroq/string/index.html for descriptions.
Python, for example, uses (or used?) the algorithm described at http://effbot.org/zone/stringlib.htm http://effbot.org/zone/stringlib.htm , for the reasons listed therein.