Consider the following algorithm (Note: For positive integers, $p,q,p/q$ denotes the floor of the rational number $\dfrac{p}{q}$, assume that given $p,q,p/q$ can be computed in one step):
$\textbf{Input:}$ Two positive integers $a,b,a\geq b.$
$\textbf{Output:}$ A positive integers $g.$
while(b>0) {
x = a – (a/b)*b;
a = b;
b = x;
}
g = a;
Suppose $K$ is an upper bound on $a$. How many iterations does the above algorithm take in the worst case?
- $\Theta(\log K)$
- $\Theta({K})$
- $\Theta({K\log K})$
- $\Theta({K^{2}})$
- $\Theta({2^{K}})$