Skip to content

Commit 41712e0

Browse files
edited Z-Algorithm README
1 parent a172311 commit 41712e0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Z-Algorithm/README.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func ZetaAlgorithm(ptrn: String) -> [Int]? {
8686
}
8787
```
8888

89-
Let's make an example reasoning with the code above. Let's consider the string `P = “abababab"`. The algorithm begins with `k = 1`, `left = right = 0`. So, no Z-box is "active" and thus, because `k > right` we start with the character comparisons beetwen `P[1]` and `P[0]`.
89+
Let's make an example reasoning with the code above. Let's consider the string `P = “abababbb"`. The algorithm begins with `k = 1`, `left = right = 0`. So, no Z-box is "active" and thus, because `k > right` we start with the character comparisons beetwen `P[1]` and `P[0]`.
9090

9191

9292
01234567
@@ -171,6 +171,6 @@ We scan the Z-array and at position `10` we find `Z[10] = 4 = n`. So we can repo
171171
As said before, the complexity of this algorithm is linear. Defining `n` and `m` as pattern and text lengths, the final complexity we obtain is `O(n + m + 1) = O(n + m)`.
172172

173173

174-
Credits: This code is based on the handbook ["Algorithm on String, Trees and Sequences: Computer Science and Computational Biology"]() by Dan Gusfield, Cambridge University Press, 1997.
174+
Credits: This code is based on the handbook ["Algorithm on String, Trees and Sequences: Computer Science and Computational Biology"](https://books.google.it/books/about/Algorithms_on_Strings_Trees_and_Sequence.html?id=Ofw5w1yuD8kC&redir_esc=y) by Dan Gusfield, Cambridge University Press, 1997.
175175

176176
*Written for Swift Algorithm Club by Matteo Dunnhofer*

0 commit comments

Comments
 (0)