0

I am looking for the run time of the following pseudo code.

FunctionA(n)
a ← 2
b ← 2n²
while b>1
    a ← a +1 
    c ← n
    while c ≥ n
        b ← b - a
        a ← a/2
        c ← 2n/c

So I think the inner while loop has a run time complexity which will be definde by the outer loop since c is allways 2 and because it allways executes as long as the outer loop runs. The outer loop decreases b with every step by 1 and a. a is allways the half of the precursor. Therefor I have the feeling that the outer loop runs $\Theta(log_2(n))$ and hence the result is $\Theta(2*log_2(n))$. Would somebody comfirm this?

gamma
  • 135
  • 4

0 Answers0