Boyer Moore Algorithm Implementation?

送分小仙女□ 提交于 2019-12-22 10:55:42

问题


Is there a working example of the Boyer-Moore string search algorithm in C? I've looked at a few sites, but they seem pretty buggy, including wikipedia.

Thanks.


回答1:


The best site for substring search algorithms:

http://igm.univ-mlv.fr/~lecroq/string/




回答2:


There are a couple of implementations of Boyer-Moore-Horspool (including Sunday's variant) on Bob Stout's Snippets site. Ray Gardner's implementation in BMHSRCH.C is bug-free as far as I know1, and definitely the fastest I've ever seen or heard of. It's not, however, the easiest to understand -- he uses some fairly tricky code to keep the inner loop as a simple as possible. I may be biased, but I think my version2 in PBMSRCH.C is a bit easier to understand (though definitely a bit slower).

1 Within its limits -- it was originally written for MS-DOS, and could use a rewrite for environments that provide more memory.
2 This somehow got labeled as "Pratt-Boyer-Moore", but is actually Sunday's variant of Boyer-Moore-Horspool (though I wasn't aware of it at the time and didn't publish it, I believe I actually invented it about a year before Sunday did).



来源:https://stackoverflow.com/questions/5423886/boyer-moore-algorithm-implementation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!