Skip to content
/ kmp Public

KMP string search algorithm implemented in Python

License

Notifications You must be signed in to change notification settings

mutux/kmp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

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!

Releases

No releases published

Packages

No packages published

Languages