A bi-directoinal variation of the O(NP) edit distance algorithm