Is it possible I am completely overthinking the complexity of an operation when I should only count it as one? This is an assignment question I have from my class.
Algorithm Power(n)
Pre: n :: Integer, n > 0
i = 1
while (i < n)
print i
i = i * 3
done
I am completely unsure of myself and think I am over-thinking the question
the time complexity O(N) before simplification would be O(n) = 1 + (3n + ? + 1) The amount of times i = i*3 is done is once per loop but the variable "i" grows at an accelerating rate per iteration does this actually matter or am I over-thinking things too much?
Is it O(n) because it is just one loop or more complex than that and something along the lines of O(log n) or O(n^(1/3)) due to "i" accelerating?