text T a b a b a a b a b a =3 pattern P b a a Algorithm Preprocessing time Matching time Naive 0 O(n-m+1)m) Rabin-Karp โ(m) O(n-m+1)m) Finite automaton O(1mโ) ฮ(n) Knuth-Morris-Pratt ฮ(1m) ฮ(n) n:the length of text T m:the length of pattern the alphabet set,consisiting ofall possible characters๐:๐กโ๐ ๐๐๐๐๐กโ ๐๐ ๐ก๐๐ฅ๐ก ๐ ๐:๐กโ๐ ๐๐๐๐๐กโ ๐๐ ๐๐๐ก๐ก๐๐๐ ๐ด:the alphabet set , consisiting of all possible characters