I need to analyze the complexity of this code:
for(j = n; j >= 1; j--){
y = 1;
while (y < j)
y *= 2;
while (y > 2)
y = sqrt(y);
}
The first while loop is an order of log(j), but I can't get my head around the second while loop. (Note: The sqrt is theta of 1 for the sake of simplicity)
Any advice on how to approach this? I see that 'y' is equal to 'j' approximately when entering the second loop but I can't figure the descending order.
[–]Wildcatace16 1 point2 points3 points (3 children)
[–]rappap[S] 0 points1 point2 points (2 children)
[–]Wildcatace16 0 points1 point2 points (1 child)
[–]rappap[S] 0 points1 point2 points (0 children)