Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added z-algo docs #51

Merged
merged 2 commits into from
Aug 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/string/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,12 @@ From [Wikipedia][hamming-distance-wiki]: In information theory, the Hamming dist
From [IBM][reverse-function-IBM]: The REVERSE function accepts a character expression as its argument, and returns a string of the same length, but with the ordinal positions of every logical character reversed.

[reverse-function-IBM]: https://www.ibm.com/docs/en/informix-servers/12.10?topic=functions-reverse-function

### [Z Algorithm](./z_algorithm.rs)

This algorithm finds any instances of a text pattern within a larger text in linear time. Let text length be n and pattern be m, then total time to compute is O(m + n) with linear space complexity. The Z-algorithm is identical to the Knuth Morris Pratt algorithm but in time and space complexity, but serves as a simpler example.
alexfertel marked this conversation as resolved.
Show resolved Hide resolved
In this algorithm, we construct a Z array.

__Properties__
* Case-performance = O(m + n)
* Case space complexity O(w)