posted 6 years ago

Which is the efficient algorithm to find the occurrence of a given string in a given large text file.

posted 6 years ago

There are two prime algorithms for doing this - the Knuth-Morris-Pratt algorithm and the Boyer-Moore algorithm. Both are fairly easy to implement and Google will provide the details. In this case I would probably use the Knuth-Morris-Pratt algorithm since it requires no backtracking.

Hs Raveendran wrote:Which is the efficient algorithm to find the occurrence of a given string in a given large text file.

There are two prime algorithms for doing this - the Knuth-Morris-Pratt algorithm and the Boyer-Moore algorithm. Both are fairly easy to implement and Google will provide the details. In this case I would probably use the Knuth-Morris-Pratt algorithm since it requires no backtracking.

Retired horse trader.

Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.