1

What is the lower bound (Omega) of Levinshtein distance algorithm in terms of time complexity? Algorithm are as described:

// len_s and len_t are the number of characters in string s and t respectively
int LevenshteinDistance(string s, int len_s, string t, int len_t)
{
  /* base case: empty strings */
  if (len_s == 0) return len_t;
  if (len_t == 0) return len_s;

  /* test if last characters of the strings match */
  if (s[len_s-1] == t[len_t-1])
      cost = 0;
  else
      cost = 1;

  /* return minimum of delete char from s, delete char from t, and delete char from both */
  return minimum(LevenshteinDistance(s, len_s - 1, t, len_t    ) + 1,
                 LevenshteinDistance(s, len_s    , t, len_t - 1) + 1,
   `             LevenshteinDistance(s, len_s - 1, t, len_t - 1) + cost));
}

I know this has been answered here: Complexity of edit distance (Levenshtein distance) recursion top down implementation. But I don't understand how Omega(2^(max(m,n))) is derived? I seek a derivation by either some kind of rule, example or mathematical derivation.

Community
  • 1
  • 1
Olle burman
  • 31
  • 10
  • The minimum Levenshtein distance between two strings is obviously 0 and it is reached when the two strings are identical. –  Feb 08 '15 at 15:23
  • I don't wonder about the lower bound of the values the algorithm returns. The question is about the lower bound (Omega) of the algorithms time complexity. Sorry if the question wasn't clear, I have now edit it. – Olle burman Feb 08 '15 at 17:26
  • 1
    https://en.wikipedia.org/wiki/Delannoy_number – David Eisenstat Feb 08 '15 at 18:02

1 Answers1

0

The recursion depth is bounded below by max(m, n) for the two first calls as they decrease the length of exactly one string each time; the recursion depth is bounded below by min(m, n) for the three calls they decrease the length of the two strings (in the best case). This explains the powers of 2 or 3.

  • Ok, that seems reasonable, but how about the bases? I mean in every recursion there's 3 new reqursions, how come that the base can be 2? – Olle burman Feb 09 '15 at 09:15
  • I don't think you understood my answer. There are only two calls that decrease the length of only one string. –  Feb 09 '15 at 09:21