good algorthm

C

chellappa

Hi Every body !
Any one Knows , very fastest ,accurate ,optimize finding word in a
given string ..
i have some algorthms ,,, but genious has good algorthm then
mine............
i need this one.....
by
(c)hellappa
 
E

Erik de Castro Lopo

chellappa said:
Hi Every body !
Any one Knows , very fastest ,accurate ,optimize finding word in a
given string ..
i have some algorthms ,,, but genious has good algorthm then
mine............
i need this one.....

Anybody with a quarter of a brain would use strstr which is
part of that standard C library.

Erik
 
B

Ben Pfaff

Boyer-moore string search algo is the fastest.

For finding a substring in a short string, any algorithm that
tries to be "smart" is probably going to be slower than a simple
algorithm.
 
W

Wolfgang Riedel

Boyer-moore string search algo is the fastest.

it depends,

(Vladimir Zabrodsky, Album of Algorithms and Techniques):

The Knuth-Morris-Pratt algorithm runs in time O(M+N), as well as in the worst
case.
It was invented independently by D. E. Knuth and V. R. Pratt and by J. H. Morris.
PRACTICE
When a text and a pattern are real strings then the fastest solution is by
REAL_STRING_MATCHER. In general case there is not an unambiguous winner.
You have to test subroutines:
NAIVE_STRING_MATCHER
KMP_MATCHER
BOYER_MOOR_MATCHER


on your data. Example, where M respectively R is number of elements in P.
respectively in Sigma. and S is number of valid shifts:

Running time in seconds for N = 100 000
Algorithm M=10,R=1999,S=50 M=10,R=4,S=10000 M=100,R=4,S=10000

Naive 16 25 150
KMP 21 22 23
Boyer-Moore 4 15 138
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top