String algorithms Summary

KMP

Single-mode string matching algorithm.

\ (S \) is the template string, \ (T \) is a text string, \ (Next (I) \) represents the string \ (T [1 ... i] \) all or suffix \ (T \ ) length of the longest prefix, using mismatch \ (next (i) \) transferred to.

Time complexity is amortized \ (O (| S | + | T |) \) .

Manacher

Seeking a string of all palindromic substrings.

Note \ (maxright \) for all points palindrome string maximum right current process, if the center of the current process \ (i \ leq maxright \) acceleration information before, can be utilized.

The time complexity is shared equally \ (O (| S |) \) .

Hash

It seems to have nothing to say.

Trie tree

It seems to have nothing to say.

Time complexity is \ (O (\ SUM | S |) \) .

AC automaton

Multimode string matching algorithm.

\ (fail (x) \) pointer to \ (X \) all suffixes represent strings is the longest prefix as a template string, and \ (the KMP \) Similarly, using mismatch \ (fail (x) \) transfer.

Some notable properties:

  1. \ (Trie \) tree node ancestor is the prefix of the string.

  2. \ (fail \) tree node ancestor is the suffix of the string.

Suffix array

All suffixes sorted in lexical order.

\ (sa [i] \) represents the first ranking for the keyword \ (i \) in the suffix.

\ (rk [i] \) is suffix \ (i \) rankings.

\ (sc [i] \) represents the second keyword ranking is \ (i \) in the suffix.

Algorithm is to use \ (rk_ {wd} \) and \ (sc_ {wd} \) Release \ (sa_ {wd} \) , then \ (sa_ {wd} \) and \ (rk_ {wd} \) Release \ (2WD rk_ {} \) , with \ (sa_ {wd} \) Release \ (2WD SC_ {} \) .

Time complexity is \ (O (| S | \ log | S |) \)

\ (height [i] \) represents ranked \ (i-1 \) suffix and ranked \ (I \) suffix \ (the LCP \) , by the nature of \ (height [rk [i- 1] ] -1 \ leq height [rk [ it]] \) in equal shares \ (O (| S |) \) is determined within a time complexity.

Often with \ (ST \) table or disjoint-set or monotonous stack or Cartesian tree merge or heuristic algorithms consumption.

Suffix automata

Constructors will not say too much trouble, time complexity is \ (O (| S | \ varsigma) \) .

All subsuffix automaton string stored in a string, the \ (\ right) in the same node on the same set of sub-string storage.

\ (The Parent \) tree is a node of the suffix string ancestor, maintenance \ (right \) method is set \ (the Parent \) tree or tree merge segment heuristic merge.

Playing the \ (Parent \) tree is a string suffix tree.

Shift-And

Single-mode string matching algorithm.

Every character in a pre-set position in the template string, with \ (the bitset \) maintenance. While matching with a \ (the bitset \) maintain the current which can be matched to the position of the template sequence, by (the bitset \) \ rapid acceleration operation can be transferred between.

When there is very easy to use wildcard string.

Time complexity is \ (O (\ FRAC {| S | \ Times | T |} {\ Omega}) \) .

Guess you like

Origin www.cnblogs.com/ErkkiErkko/p/11084522.html