Suffix automaton (SAM)

definition

Suffix automaton ( \ (\ Automaton Suffix {text} \) , abbreviated \ (\ text the SAM} {\) ). For a string \ (S \) , which corresponds to a suffix automaton is minimal deterministic finite automaton ( \ (\ the DFA {text} \) ), and accepts only accept \ (S \) suffix.

For example, the string \ (S = \ underline aabbabd} {\) , which is a suffix automaton

14807564643248.png

Wherein \ (\ textcolor [rgb] { 1,0,0} { } red status \) is the end state. You can find for \ (S \) suffix, we can from \ (S \) departing along a path marked character ( \ (\ textColor [RGB] {0,0,1} {} blue solid line \ ) ) transfer, and finally to the end state.

In particular, for the (S \) \ substring will eventually reach a valid state. For other than \ (S \) String substring will eventually "nowhere to go."

\ (\ text {SAM} \ ) is essentially a \ (\ the DFA {text} \) , \ (\ the DFA text} {\) may be a five-tuple <character set, the state set, transfer function, starting state, end state set> to represent. For those \ (\ textcolor [rgb] { 0,1,0} { } green dotted line \) Although not \ (\ text {DFA} \ ) part, but it is \ (\ text {SAM} \ ) important part, with these links \ (\ text {SAM} \ ) is even more powerful, these Jiangzai go into detail later.

Here we introduce for a given string \ (S \) how to determine its corresponding set of states and the transition function .

SAM set of states (States)

First, a concept first introduced end position of the substring collection \ (endpos \)

For \ (S \) of a substring \ (S \) , \ (endpos (S) = S \) in the (S \) \ collection of all end position appears.

String \ (S = \ underline {aabbabd } \) Example

status Substring \ (Endpos \)
\(S\) \(\varnothing\) \(\{0,1,2,3,4,5,6\}\)
\(1\) \(a\) \(\{{1,2,5}\}\)
\(2\) \(aa\) \(\{2\}\)
\(3\) \ (Re \) \(\{3\}\)
\(4\) \ (Aabb, fig, bb \) \(\{4\}\)
\(5\) \(b\) \(\{3,4,6\}\)
\(6\) \ (Aabba, abba, my father, \) \(\{5\}\)
\(7\) \ (Aabbab, abbab, chapter, chapter \) \(\{6\}\)
\(8\) \(from\) \(\{3,6\}\)
\(9\) \ (Aabbabd, abbabd, bbabd, babd, abd, bd, d \) \(\{7\}\)

Guess you like

Origin www.cnblogs.com/newbielyx/p/12153974.html