Problem Statement
Which algorithm is best suited for multiple pattern matching in a large text?
Explanation
The Aho–Corasick algorithm builds a finite state automaton combining all patterns. It finds all occurrences of multiple patterns simultaneously in linear time relative to text length.
Code Solution
SolutionRead Only
// Aho–Corasick combines all patterns in a trie with failure links.
// Example: Patterns {he, she, hers}
// Trie built once, traverse text once.
// Time: O(n + total pattern length)
// Used in text search engines and intrusion detection.Practice Sets
This question appears in the following practice sets:
