user3196347
user3196347

Reputation: 33

Big O notation of pseudocode

I am having trouble determining the runtime of the following pseudocode.

while n > 0 do
  n = n/3

It seems to be rather straight forward, but I keep confusing myself would it be log3n? I know that if it was dividing by two, it would be log2n.

The three is just throwing me off.

Thanks!

Upvotes: 1

Views: 413

Answers (1)

TypeIA
TypeIA

Reputation: 17248

The base of the logarithm is not included in big-O notation, since changing bases is simply a scalar multiple. So it's just O(log n).

Upvotes: 1

Related Questions