given:
public void trash(int n){
int i =n;
while (i > 0){
for (int j = 0; j < n; j++) {
System.out.println("*");
i = i/2;
}
}
}
I'm might argue that the time complexity for this operation is linear because comparing i > 0 would be constant and the for loop inside would be linear. Therefore give a total of linear time.
But in my head, i still think the operation is quadratic.
Could anyone please give me a clearer explanation of the complexities on nested loops. Thanks