shenqiti / kmp

KMP string search algorithm implemented in Python

Home Page:http://mutux.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KMP Knuth–Morris–Pratt string search algorithm implemented in Python

String algorithm for fun! Detailed information can be found on my blogger MuTuX.

Examples

if __name__ == "__main__":
    kmp('abcbabca','abcbabcabcbabcbabcbabcabcbabcbabca')

    kmp('abab','ababcabababc')

Results

========================================================
[-1, 0, 0, 0, 0, 1, 2, 3, 1]
0 7
15 22
26 33
[-1, 0, 0, 1, 2]
0 3
5 8
7 10

Finally

Have fun!

About

KMP string search algorithm implemented in Python

http://mutux.com

License:MIT License


Languages

Language:Python 100.0%