kmp算法[英文詳解](轉(zhuǎn))

kmp算法[英文詳解](轉(zhuǎn))

ID:26251191

大小:58.50 KB

頁數(shù):16頁

時間:2018-11-25

kmp算法[英文詳解](轉(zhuǎn))_第1頁
kmp算法[英文詳解](轉(zhuǎn))_第2頁
kmp算法[英文詳解](轉(zhuǎn))_第3頁
kmp算法[英文詳解](轉(zhuǎn))_第4頁
kmp算法[英文詳解](轉(zhuǎn))_第5頁
資源描述:

《kmp算法[英文詳解](轉(zhuǎn))》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。

1、Knuth-Morris-PrattstringmatchingTheproblem:givena(short)patternanda(long)text,bothstrings,determinewhetherthepatternappearssomewhereinthetext.?Lasttime?wesawhowtodothiswithfiniteautomata.Thistimewe'llgothroughthe?Knuth-Morris-Pratt?(KMP)algorithm,whichcanbethoughtofasaneffici

2、entwaytobuildtheseautomata.Ialsohavesome?workingC++sourcecodewhichmighthelpyouunderstandthealgorithmbetter.Firstlet'slookatanaivesolution.supposethetextisinanarray:charT[n]andthepatternisinanotherarray:charP[m].Onesimplemethodisjusttotryeachpossiblepositionthepatterncouldappe

3、arinthetext.Naivestringmatching:for(i=0;T[i]!='