Hello
Please excuse my lack of knowledge to python, but I just cannot understand how time complexity works. I've read many threads on this forum regarding time complexity but I am still quite confused.
Our prof has given us this example:
def foo(n):
! while (n > 0):
! ! print n
! ! n = n / 2
and this answer:
complexity = 3n + 1
! simplifying:
! ! removing constants: complexity = O(n) eg- linear with "n"
I understand that a while loop will produce N and if you simplify you will get O(N).
But how do you get 3n + 1 before simplifying to the big O?