Computing Atlas

How Computing Was Built
Sign In
Text size
100%
Theme
Algorithm

Aho-Corasick Algorithm

String Algorithm

The Aho-Corasick algorithm searches text for every occurrence of any pattern from a fixed set of patterns simultaneously, in a single pass over the text, by first building a trie of all the patterns augmented with failure links that let the search resume at the correct point in another pattern whenever a partial match fails, similar in spirit to the failure function used in single-pattern Knuth-Morris-Pratt search but generalized to many patterns at once. It runs in time proportional to the length of the text plus the total length of the patterns plus the number of matches found, independent of how many patterns are in the set. Alfred Aho and Margaret Corasick published the algorithm in 1975, and it remains the standard method behind many multi-pattern text search and intrusion detection tools.

Facts
Time Complexity
Linear in the length of the strings plus the length of the searched text plus the number of output matches 2
Credited To
Alfred V. Aho and Margaret J. Corasick, 1975 2
Time Complexity
Time Complexity (category)
Linear Time -- O(n) 1
Connections

Invented By

Alfred Aho, Pioneers

Alfred Aho co-invented this string-matching algorithm with Margaret Corasick at Bell Labs, published in 1975.

Source Wikipedia: Alfred Aho
Sources
1. Aho-Corasick Algorithm (Wikipedia)
Wikipedia infobox: time complexity linear
Quote, Wikipedia infobox: time complexity linear
linear
View the Source
2. Aho-Corasick algorithm, Wikipedia
  • Opening paragraph, sentence on complexity
    The complexity of the algorithm is linear in the length of the strings plus the length of the searched text plus the number of output matches.
  • Opening paragraph, sentence on inventors
    invented by Alfred V. Aho and Margaret J. Corasick in 1975.
View the Source
Comments (0)
No comments yet. Be the first to share a thought.
Reader Challenges (0)
No disputes yet. Spotted an error or a better source? Open the first one.