Reputation:
How can I calculate the time complexity?
While(n>0) For j in n Count+=1 n = n/2
Upvotes: 1
Views: 321
Reputation: 1043
O(n).
n+ n/2 + n/4 + ... = 2n = O(n)
Upvotes: 9