The Aho-corasick algorithm is referred to as the AC algorithm, by preprocessing the pattern string to determine the finite state automata, the scanned text can be finished again. Its complexity is O (n), which is independent of the number and length of the pattern string. The mind automata accepts characters in the order of text characters, and the state transitions occur. These states cache the "Success by character transfer (but not the end of the pattern string)", "succeeded by character transfer (end of pattern string)", "failed by character transfer" Three cases of jump and output, thus reducing complexity. There are three core functions in the basic structure AC algorithm, namely: success; Successfully transferred to another State (also called a goto table or success table) failure; Not...
Read on : Java Implementation and analysis of code farm»aho-corasick algorithm
original link : http://www.hankcs.com/program/algorithm/implementation-and-analysis-of-aho-corasick-algorithm-in-java.html
Java implementation and analysis of Aho-corasick algorithm