Imagine you need to answer the question "does this pattern appear anywhere in this text?" — thousands of times, for thousands of different patterns, all against the same long text. A naive search re-scans the text from scratch every time. A smarter idea: preprocess the text once into an index that answers each query instantly.
The suffix automaton (also called a DAWG — Directed Acyclic Word Graph) is the most elegant such index known. It is a finite-state machine — a compact directed graph — with one extraordinary property: a path through it spells out a string if and only if that string is a substring of the original text. Feed it any candidate pattern; if the automaton accepts it, the pattern is there.
What makes it remarkable is not what it does but how small it is. For a string of length , the suffix automaton has at most states and at most transitions — proven limits, impossible to beat. And yet it is built in time and space by a simple online algorithm: extend the automaton one character at a time, never looking back. Proved and published by Anatolii Blumer, Janet Blumer, Andrzej Ehrenfeucht, David Haussler, and Ross McConnell in 1985.
The suffix automaton sits in the heart of modern text processing — DNA search, plagiarism detection, data compression — and it connects deeply to the related concepts of pattern matching and sequence alignment.
Comments
Loading comments...