Levi H
Levi H

Reputation: 3586

Faster way to search for a string than the boyer moore algorithm?

Is there any faster way to search for a string in a file?

Upvotes: 5

Views: 1967

Answers (3)

Yuf
Yuf

Reputation: 610

If you know anything specific about the file, there could be faster algorithms.

For example, if the file contains many repeating characters/patterns and you need to do a large number of searches, you could try using Suffix Trees: http://marknelson.us/1996/08/01/suffix-trees/

Depending on your file and the quantity of searches you need on that one file, the answer for the fastest search algorithm may change.

Upvotes: 2

aaaa bbbb
aaaa bbbb

Reputation: 3043

The Turbo Boyer-Moore algorithm is faster, but requires more space. http://www-igm.univ-mlv.fr/~lecroq/string/node15.html

Upvotes: 2

Aykut Çevik
Aykut Çevik

Reputation: 2088

Look at this site, where you can also see the matching time for each of the algorithms.

Upvotes: 5

Related Questions