This algorithm is generalized by the Aho-Corasick algorithm, which builds a more complex automaton in order to search for multiple strings at once. However, certain pieces of the string to search for might share some overlapping structure, so some new transitions are added that take the automaton back to an earlier (but not the first) state when a character is read. By default, the transitions are such that matching the next character advances to the next state in the machine and reading an invalid character transitions back to the beginning. The automaton that's constructed works by having one state for each amount of the string that has been matched so far. The net result is a linear-time algorithm for string matching. Using a very clever linear-time preprocessing of the string to search for, a matching automaton can be constructed, and the automaton can then be simulated on the string to search in in linear time. The KMP matching algorithm is based on finite automata and works by implicitly building the transition table for an automaton that matches the string.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |