Edit Distance Problem

Question–>
https://practice.geeksforgeeks.org/problems/edit-distance3702/1

I understand the recusive cases that when the last character of both the string are same then recur foe m-1,n-1, but they are not equal then we have to take min of the recursive step of step insert delete and replace
but i cannot understand how the recurrence relation is formed–>
if (str1[m - 1] == str2[n - 1])
return editDist(str1, str2, m - 1, n - 1);

// If last characters are not same, consider all three
// operations on last character of first string,
// recursively compute minimum cost for all three
// operations and take minimum of three values.
return 1
       + min(editDist(str1, str2, m, n - 1), // Insert
             editDist(str1, str2, m - 1, n), // Remove
             editDist(str1, str2, m - 1,
                      n - 1) // Replace
         );

when we are inserting is not the recurrence relation be
editDistance(m+1,n);

Didn’t get what you are saying in this?

suppose
insertion
string s1=“star”; m=s1.length();
string s2=“stary”; n=s2.length();
so we have insert y in the index m+1 right and recur for editdistance(s1,s2,m+1,n);?

I guess the question approach is not clear to you. Watch this video it will clear all your doubt. I am attaching the link just see it once. If have any other doubts left ask me.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.