Consider below code stuff of the dynamic programming approach of the LCS.
(考虑以下LCS动态编程方法的代码。)
int lcs( char[] X, char[] Y, int m, int n )
{
if (m == 0 || n == 0)
return 0;
if (X[m-1] == Y[n-1])
return 1 + lcs(X, Y, m-1, n-1);
else
return max(lcs(X, Y, m, n-1), lcs(X, Y, m-1, n));
}
As we can see if X[m-1] != Y[n-1], we take the max value among given two lcs values.
(如我们所见,如果X [m-1]!= Y [n-1],我们取给定两个lcs值中的最大值。)
So, my problem is what happens if we change max to min as below. (所以,我的问题是,如果我们将max更改为min,将会发生什么情况。)
return min(lcs(X, Y, m, n-1), lcs(X, Y, m-1, n));
I mean, what would be my final out come if I changed the return statement as above?.
(我的意思是,如果我如上所述更改return语句,最终结果将是什么?)
ask by TTDS translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…