Skip to content

Commit

Permalink
feat: add z-algo docs (#51)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander González <[email protected]>
  • Loading branch information
dlkritter and alexfertel authored Aug 4, 2023
1 parent c1cd331 commit 69232d8
Showing 1 changed file with 9 additions and 0 deletions.
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 instances of a text pattern within a larger text in linear time. Let the text length be `n` and pattern be `m`, then the total time to compute is `O(m + n)` with linear space complexity. The Z-algorithm is identical to the Knuth Morris Pratt algorithm in time and space complexity, but serves as a simpler example.
In this algorithm, we construct a Z array.

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

0 comments on commit 69232d8

Please sign in to comment.