5

Given two functions:

f(n)=O(log2n) and g(n)=O(log10n)

Does one of these dominate the other?

user513951
  • 10,578
  • 7
  • 59
  • 72
Deekor
  • 8,371
  • 13
  • 64
  • 112

3 Answers3

3

Remember that logs of any base can be converted into a common base that only varies by a constant.

enter image description here

Therefore they both have the same upper bound

James Sampica
  • 11,632
  • 3
  • 58
  • 82
1

No.

The difference between bases is a difference by a constant, and constants are not considered in asymptotic efficiency.

In this case, f(n) = O(g(n)) = O(lg(n)) In fact, f(n) = Θ(g(n)) = Θ(lg(n))

drew moore
  • 28,107
  • 16
  • 72
  • 106
0

First you must understand what it means for a function f(n) to be O( g(n) ).

The formal definition is: *A function f(n) is said to be O(g(n)) iff |f(n)| <= C * |g(n)| whenever n > k, where C and k are constants.*

so let f(n) = log base a of n, where a > 1 and g(n) = log base b of n, where b > 1

NOTE: This means the values a and b could be any value greater than 1, for example a=100 and b = 3

Now we get the following: log base a of n is said to be O(log base b of n) iff |log base a of n| <= C * |log base b of n| whenever n > k

Choose k=0, and C= log base a of b.

Now our equation looks like the following: |log base a of n| <= log base a of b * |log base b of n| whenever n > 0

Notice the right hand side, we can manipulate the equation: = log base a of b * |log base b of n| = |log base b of n| * log base a of b = |log base a of b^(log base b of n)| = |log base a of n|

Now our equation looks like the following: |log base a of n| <= |log base a of n| whenever n > 0

The equation is always true no matter what the values n,b, or a are, other than their restrictions a,b>1 and n>0. So log base a of n is O(log base b of n) and since a,b doesn't matter we can simply omit them.

You can see a YouTube video on it here: https://www.youtube.com/watch?v=MY-VCrQCaVw

You can read an article on it here: https://medium.com/@randerson112358/omitting-bases-in-logs-in-big-o-a619a46740ca

tempmail
  • 126
  • 1
  • 4