Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/likejazz/boyer-moore-string-search
Boyer Moore string search implementation in C
https://github.com/likejazz/boyer-moore-string-search
Last synced: about 2 months ago
JSON representation
Boyer Moore string search implementation in C
- Host: GitHub
- URL: https://github.com/likejazz/boyer-moore-string-search
- Owner: likejazz
- License: mit
- Created: 2014-06-26T04:09:51.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-06-24T07:33:35.000Z (over 9 years ago)
- Last Synced: 2024-03-15T05:41:42.488Z (9 months ago)
- Language: C
- Size: 279 KB
- Stars: 34
- Watchers: 4
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
boyer-moore-string-search
=========================[Boyer-Moore string search algorithm](http://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm) implementation in C.
The algorithm performs its matching backwards, from right to left and proceeds by iteratively matching, shifting the pattern, matching, shifting, etc. The shift amount is calculated by applying these two rules:
1. the bad character rule
2. good suffix ruleAn actual shifting offset is the maximum one of them.
* `delta1` - the "Bad Character" table
This table contains an entry for every character in the alphabet. The entry for char specifies how far the pattern should be right shifted when chars found in the string and it does not match the current pattern character.
* `delta2` - the "Good Suffix" table
This table contains an entry for each character in the pattern. The entry for pattern[j] specifies how far the current string position should shift to the right when pattern[j-1] does not match the string but the suffix at pattern[j .. patlen-1] does match.
## Usage
To compile and execute the tests:
$ make
$ ./bmTo remove the compiled file:
$ make clean
## Sample Output
![Sample Output](https://raw.githubusercontent.com/likejazz/boyer-moore-string-search/master/sample-output.png)