I came accros this example while working on Big-O notation
x=n
while(x>0)
{
y=x
while(y>0)
{
y=y-1
}
x = x/2
}
Could, you explain me why it seems to have a O(N) complexity ?
This is new for me but I would expect it to be N LogN.
What am I missing ?
Thanks,
EDIT: this piece of code comes from here https://www.quora.com/How-can-we-check-for-the-complexity-log-n-and-n-log-n-for-an-algorithm?encoded_access_token=1b7e0a4d10f84d50b5fea810f5a89cea