I thought I understood Big-O fully and I think I still have an okay understanding but I wanted to make sure that I am understanding it correctly.
If I have code similar to this:
while(number > 0)
{
sum += number;
number /= 2;
}
I believe that my Big-O runtime would be O(N) since the loop would run, by my calculations, for O(N/2) and then each of the statements in the loop would run for O(1) so we end up with O(N ^ 1/2) + O(1) + O(1) so O(N ^ 1/2 + 1 + 1) and we drop the constants leaving us with O(N ^ 1/2) or O(sqrt N) complexity... I believe this would be log(n) Big-O runtime but just wanted some clarification and verification to make sure I understood this concept. I have read up quite a bit on this topic and watched videos - I just couldn't find a similar enough example anywhere and the 'number /= 2' is what is throwing me off.
For the record, it was a homework question that got me thinking about this.