From c1cc49ec4b361dc693b6f97d5418fd8b178a7282 Mon Sep 17 00:00:00 2001 From: Dylan Kritter <100829534+dlkritter@users.noreply.github.com> Date: Tue, 20 Dec 2022 13:06:49 +0200 Subject: [PATCH 1/2] added z-algo docs --- src/string/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/string/README.md b/src/string/README.md index cd759f3..c33ae09 100644 --- a/src/string/README.md +++ b/src/string/README.md @@ -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. +In this algorithm, we construct a Z array. + +__Properties__ +* Case-performance = O(m + n) +* Case space complexity O(w) From fe2dd86a3735b4cd7388a98fb605b1b9b4ce7b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Gonz=C3=A1lez?= Date: Fri, 4 Aug 2023 16:26:43 +0200 Subject: [PATCH 2/2] fix(docs): update src/string/README.md --- src/string/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/string/README.md b/src/string/README.md index c33ae09..b29a60c 100644 --- a/src/string/README.md +++ b/src/string/README.md @@ -56,7 +56,7 @@ From [IBM][reverse-function-IBM]: The REVERSE function accepts a character expre ### [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. +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__