#include<bits/stdc++.h>
using namespace std;
string str1, str2;
int minimum(int a, int b, int c)
{
return min(a, min(b, c));
}
int med(int n, int m)
{
if(n == 0)
return m;
if(m == 0)
return n;
if(str1[n-1] == str2[m-1])
return med(n-1, m-1);
return 1 + minimum(med(n, m-1), med(n-1, m), med(n-1, m-1));
}
int main()
{
cout << "Enter First String : ";
cin >> str1;
cout << "Enter Second String : ";
cin >> str2;
int n = str1.size();
int m = str2.size();
cout << "Minimum Edit Distance : " << med(n, m) << "\n";
return 0;
}
Comments
Post a Comment