What is the time complexity of the algorithm in the following code? it's best to explain the idea.

what is the time complexity of the algorithm in the following code? it"s best to explain the idea

.
i= s = 0;
while (s<n)
{
    iPP;
    s+=i;
}
Feb.19,2022

Let I just stop. From the summation formula, we get (0 + I) * (I + 1) / 2 > = n , retain the highest order I ^ 2 , and get O (sqrt (n)) time complexity.


violence (because I am lazy but diligent)

$cat complex.groovy

  

O (n ^ 1 / 2)

Menu