Search code examples
algorithmbig-ologarithm

Proof of O(loga n) = O(logb n), for any base a or b


I am revising for my exams and this question appears on a past paper:

Show that O(loga n) = O(logb n) for any choice of logarithmic bases a and b working from the mathematical definition of the order notation f(n) E O(g(n)).

Could someone please show me how to solve this?


Solution

  • The rule for changing base of a logarithm is: log_b(n) = log_a(n) / log_a(b).

    This immediately implies log_b(n) = O(log_a(n)) and by symmetry log_a(n) = O(log_b(n)).