Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc2e90ab

Browse files
authored
Fix a subscript error in the Prefix function page (#684)
Co-authored-by: iamspzero <li.zandeng@gmail.com>
1 parent841f81d commitc2e90ab

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎src/string/prefix-function.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ To accomplish this, we have to use all the information computed in the previous
6363
So let us compute the value of the prefix function $\pi$ for $i + 1$.
6464
If $s[i+1] = s[\pi[i]]$, then we can say with certainty that $\pi[i+1] = \pi[i] + 1$, since we already know that the suffix at position $i$ of length $\pi[i]$ is equal to the prefix of length $\pi[i]$.
6565
This is illustrated again with an example.
66-
$$\underbrace{\overbrace{s_0 ~ s_1 ~ s_2}^{\pi[i]} ~ \overbrace{s_3}^{s_3 = s_{i+1}}}\_{\pi[i+1] = \pi[i] + 1} ~ \dots ~ \underbrace{\overbrace{s_{i-2} ~ s_{i-1} ~ s_{i}}^{\pi[i]} ~ \overbrace{s_{i+1}}^{s_3 =s_i + 1}}\_{\pi[i+1] = \pi[i] + 1}$$
66+
$$\underbrace{\overbrace{s_0 ~ s_1 ~ s_2}^{\pi[i]} ~ \overbrace{s_3}^{s_3 = s_{i+1}}}\_{\pi[i+1] = \pi[i] + 1} ~ \dots ~ \underbrace{\overbrace{s_{i-2} ~ s_{i-1} ~ s_{i}}^{\pi[i]} ~ \overbrace{s_{i+1}}^{s_3 =s_{i + 1}}}\_{\pi[i+1] = \pi[i] + 1}$$
6767
6868
If this is not the case, $s[i+1] \neq s[\pi[i]]$, then we need to try a shorter string.
6969
In order to speed things up, we would like to immediately move to the longest length $j \lt \pi[i]$, such that the prefix property in the position $i$ holds, i.e. $s[0 \dots j-1] = s[i-j+1 \dots i]$:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp