I have this code, but show me a error with System.Math.Min
. It shows it to me where is the bold: return System.Math.Min(System.Math.Min(dist(.
The error is:
byte Math.Min(byte val1, byte val2) (+ 10 overloads)
Returns the smaller of two 8-bit unsigned integers.
Return
Parameter val1 or val2, whichever is smaller.
Someone who can explain to me and how I can fix it.
The complete code is:
static int dist(string word1, int m, string word2, int n)
{
int cost;
if( m == 0)
{
return m;
}
if (n == 0)
{
return n;
}
if (word1[m-1] == word2[n - 1])
{
cost = 0;
}
else
{
cost = 1;
}
return System.Math.Min(System.Math.Min(dist(
word1, m, word2, n - 1) + 1),
dist(word1, m, word2, n-1),
dist(word1, m - 1, word2, n - 1) + cost);
}
static void Main(string[] args)
{
string word1 = "open", word2 = "peon";
int m = word1.Length;
int n = word2.Length;
Console.WriteLine("The Levenshtein distance is " +
dist(word1, m, word2, n));
}