Reputation: 12517
I have the following question:
Is the following statement true or false?
All logs to base 2
log2n is a member of O(log(n))
My attempt:
Now correct me if I'm wrong, but I have to find values for n (variable) and c (constant) which either prove or disprove this...
Generally this seems to be true:
Choose
n0 = 2, c = 3 -> TRUE
n1 = 3, c = 3 -> TRUE
n2 = 4, c = 3 -> TRUE
Therefore, the statement seems true, logn increases as n does. But there are also values for which the above statement will never hold:
e.g.
Choose c = 1 evaluates to greater than zero regardless of the increasing value of n.
So I am confused as to whether this is true or false....
Upvotes: 1
Views: 407
Reputation: 500367
You could just use the fact that the logarithm of a product is the sum of the logarithms of the factors:
log(2n) = log(2)+log(n) = O(log(n))
Upvotes: 2