I know that if implemented recursively the extended euclidean algorithm has time complexity equals to O(n^3). I was wandering if time complexity would differ if this algorithm is implemented like the following. What is the time complexity of the following implementation of the extended euclidean algorithm?
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;
}