brentonashworth / clj-diff

Diff for Clojure Sequences
Eclipse Public License 1.0
114 stars 23 forks source link

O(n²) space complexity in ses function? #7

Open PerMildner opened 6 years ago

PerMildner commented 6 years ago

Unless I am mistaken, the Shortest Edit Script function (ses) is not linear in the length of the input. Instead it uses quadratic space for its (mis-named) fp map, in the worst case.

By using the divide-and-conquer idea from Hirschberg, the original Myers algorithm uses linear space both for computing the edit distance D, and for computing the Shortest Edit Script, and this is also what Wu et al. claim is possible with their improved O(NP)-time algorithm.