This package contains implementation of 4 dynamic programming algorithms:
- Levenshtein distance (edit distance)
- Needleman-Wunsch algorithm (sequence alignment)
- Hirschberg algorithm (space-optimised NW algorithm)
- Longest common subsequence
d := LevenshteinDistance([]byte("kitten"), []byte("sitting"), nil, nil)
//d ==3
The NW implementation requires the user to provide a similarity function that can return the similarity between two points
func similarity(a byte, b byte) int {
if a == b {
return 1
}
return -1
}
a := []byte("ABCDEF")
b := []byte("ABCCDEF")
z, w := NeedlemanWunsch(a, b, -1, similarity, f)