Skip to content

[EN] Implementation of the Knuth-Morris-Pratt algorithm / [FR] Implémentation de l'algorithme Knuth-Morris-Pratt

License

Notifications You must be signed in to change notification settings

fbonhomm/knuth-morris-pratt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License: MIT CI

Knuth-Morris-Pratt Algorithm

[EN]
Implementation of the Knuth-Morris-Pratt algorithm or KMP algorithm in GO.

Knuth-Morris-Pratt is a substring search algorithm.

[FR]
Implémentation de l'algorithme de Knuth-Morris-Pratt ou l'algorithme KMP en Go.

Knuth-Morris-Pratt est un algorithme de recherche de sous-chaîne.

Technology

Usage

CLI:

go test -v test/

CODE:

import kmp "github.com/fbonhomm/knuth-morris-pratt/source"

var index, length int
var buffer = []byte("abc abcdab abcdabcdabde")
var pattern = []byte("abcdabd") // 7
var pattern1 = []byte("abcdabdr") // 8

index = kmp.Search(buffer, pattern) // 15
index = kmp.Search(buffer, pattern1) // -1

Explanations

Links

https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm https://dev.to/girish3/string-matching-kmp-algorithm-cie
https://www.geeksforgeeks.org/kmp-algorithm-for-pattern-searching/

About

[EN] Implementation of the Knuth-Morris-Pratt algorithm / [FR] Implémentation de l'algorithme Knuth-Morris-Pratt

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages