https://github.com/bluss/galil-seiferas
Galil-Seiferas algorithm: String search in constant space, linear time, for nonorderable alphabets
https://github.com/bluss/galil-seiferas
exact-string-matching rust string-search
Last synced: about 1 year ago
JSON representation
Galil-Seiferas algorithm: String search in constant space, linear time, for nonorderable alphabets
- Host: GitHub
- URL: https://github.com/bluss/galil-seiferas
- Owner: bluss
- License: apache-2.0
- Created: 2017-11-05T22:50:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-24T09:57:43.000Z (almost 8 years ago)
- Last Synced: 2025-04-09T10:05:59.519Z (about 1 year ago)
- Topics: exact-string-matching, rust, string-search
- Language: Rust
- Homepage: https://docs.rs/galil-seiferas/
- Size: 115 KB
- Stars: 5
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README-crates.io.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
General string search in constant space, linear time, for nonorderable alphabets.
Also known as exact string matching.
In Rust terms this means we can define the function:
```rust
fn gs_find(text: &[T], pattern: &[T]) -> Option {
// ...
}
```
and the function computes in **O(n)** time and **O(1)** space.
In the worst case, this algorithm makes **4 n** character comparisons.
Note that the Crochemore-Perrin (“Two Way” algorithm) is much superior if
there is a linear order for the alphabet.
This work is Copyright 2017 by Ulrik Sverdrup "bluss"; see license terms
in the package.
# References
Both papers are recommended reading. The comments in this crate’s
implementation are also meant to explain and point out important details,
so that’s recommended reading too.
- [GS] Z. Galil and J. Seiferas,
*Time-Space-Optimal String Matching*,
Journal of Computer and System Sciences (1983)
- [CR] M. Crochemore and W. Rytter,
*Squares, Cubes, and Time-Space Efficient String Searching*,
Algorithmica (1995)