我知道如果递归实现,扩展欧几里德算法的时间复杂度等于O(n ^ 3)。如果时间复杂度不同,如果这个算法实现如下,我就会徘徊。 以下实施扩展欧几里德算法的时间复杂度是多少?
public static BigInteger FirstCoefficientOfBezout(BigInteger a, BigInteger b)
{
BigInteger x=BigInteger.ZERO;
BigInteger y =BigInteger.ONE;
BigInteger X =BigInteger.ONE ;
BigInteger Y = BigInteger.ZERO;
BigInteger t;
while (b !=BigInteger.ZERO)
{
BigInteger q = a.divide(b);
BigInteger r = a.mod(b);
a = b;
b = r;
t = x;
x = X.subtract(q.multiply(x));
X = t;
t = y;
y = Y.subtract(q.multiply(y));
Y = t;
}
return X;
}