Pattern Searching | Set 6 (Efficient Construction of Finite Automata) - GeeksforGeeks Algorithm: 1) ...

Please Visit: http://ift.tt/1ajReyV



Pattern Searching | Set 6 (Efficient Construction of Finite Automata) - GeeksforGeeks

Algorithm:

1) Fill the first row. All entries in first row are always 0 except the entry for pat[0] character. For pat[0] character, we always need to go to state 1.

2) Initialize lps as 0. lps for the first index is always 0.

3) Do following for rows at index i = 1 to M. (M is the length of the pattern)

…..a) Copy the entries from the row at index equal to lps.

…..b) Update the entry for pat[i] character to i+1.

…..c) Update lps “lps = TF[lps][pat[i]]” where TF is the 2D array which is being constructed.

http://ift.tt/Y6XfQl

http://ift.tt/1mWwhqB



Pattern Searching | Set 6 (Efficient Construction of Finite Automata) - GeeksforGeeks







from Public RSS-Feed of Jeffery yuan. Created with the PIXELMECHANICS 'GPlusRSS-Webtool' at http://gplusrss.com http://ift.tt/Y6Xg6C

via LifeLong Community

No comments:

Post a Comment