"Algorithm" suffix automaton sam

Source: Internet
Author: User

"Right Collection"

The suffix automaton is really superior to the suffix tree in that it combines the finite state automata to realize the space-time complexity of O (n).

Trans (S,STR) indicates the status of S+STR arrival.

ST (str) =trans (INIT,STR) is the only state that includes the substring of STR (a substring can only belong to one state)

Defines a collection of right endpoint locations where string a appears in S (a) =r1,r2...rn.

The right set of a state s in a Sam is a (s), then the state s represents all [the substring a of =right (s)], then the length of the substring A is actually represented by the state S is within a range, denoted by [Min (s), Max (s)]. The shorter the string, the larger the right collection.

It is easy to prove that any State A and b,right (a) and right (b) either contain or do not intersect. (The obvious conclusion is that the proof of the paper is more rigorous)

★ In the suffix automaton, a state s (or "node S") represents a number of substring a of right (a) =right (s), whose length is [MIn (s), Max (s)], thus achieving the purpose of the state number O (n).

The tree-containing relationship formed by the right collection is called the parent tree, and the tree Edge is directed by the child to the father, which is a mismatch edge in the SAM.

The parent tree goes from top to bottom, the substring length expands, and the right collection is smaller, and the right collection of parents contains the right collection of child nodes .

Fa=parent (s) when and only if FA is the smallest and satisfies right (s)? Right (FA) node, (from son to Father, substring is shortened slightly, right set becomes larger)

Also Max (FA) =min (s)-1, essentially requires that there is not a right subset between FA and S X to satisfy right (s)? Right (x)? Right (FA).

"Linear Construction Sam"

The linear construct uses the increment method, that is, Sam (t), known as the string T, L=len (t), adds the character x at the end, constructs the SAM (Tx), and transfers the following:

① real-side transfer rule: T=trans (s,x) indicates that s--->t is labeled as an edge of X, and if right (s) ={r1,r2...rn}, then right (t) ={ri+1|s[ri+1]=x}.

② Virtual edge Transfer rule: Parent tree side satisfies right (s)? Right (FA), Max (FA) =min (s)-1 (meaning above)

By adding X, consider that all right collections contain the node v1,v2...vk of L, apparently they are a chain from root to leaf in the parent tree.

Defines the leaf node v1=p=st (T) (that is, p for the entire string), right (p) ={l}, which may be ranked as V1=p...vk=root from descendant to ancestor.

Also new node np=st (Tx), right (NP) ={l+1}.

Consider node V,right (v) ={r1,r2...rn=l}

According to the transfer rule ①, if there is no s[ri+1]=x except RN, then the node v does not exist in trans (v,x).

According to the transfer rule ②, the farther right set gradually expands until the node VP exists trans (vp,x), then the v1~vp-1 only need to connect to the NP with the edge labeled X (Np=trans (v,x)), and Vp~vk already exists trans (v,x).

Make trans (vp,x) =q, when Max (q) =max (VP) +1, only insert l+1 in the right collection of Q.

The following focuses on the case of Max (q) >max (VP) +1.

"Algorithm" suffix automaton sam

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.