
This is just a more formal and generalized way of expressing your intuition. There are some fence post issues and that's why they have the min function there, but the intuition still holds.īy considering all strings, $P_k$, that start at the beginning of the pattern shorter than the current position of the read pattern, $P_q a$, we test each $P_k$ to be a suffix of $P_q a$ and choose the maximum. 3) Do following for rows at index i 1 to M. For pat 0 character, we always need to go to state 1. Beginning and ending positions of matches are indicated at the bottom. The automaton processes each input character once. It implements recognition of the pattern to match. The random string at the top is processed by the automaton shown in the graph. otherwise (q, a, p) is in E such that p is the longest suffix of qa which is a prefix of x. All entries in first row are always 0 except the entry for pat 0 character. Matching of strings can be done by automata. (q, a, qa) is in E if and only if qa is also a prefix of x. Once that is found, we know we can 'skip ahead' and transition to that state instead of the beginning. In the Handbook of Exact String Matching algorithms, it describes the transition set for a basic string matching automaton as: for. In words, the loop that line 6 is contained in is saying "Find the maximum suffix of the strings shorter than the current state $q$ that start at $P$". Meaning, $w$ can be found as a suffix of $x$. Finite State Automata A FSA has circles to represent states and arrows to represent transitions between states Arrows are labeled with a character.
