Why we do not consider base of log in time complexity
For asymptotic complexity, base of logarithms does not matter, but why ?
In this article I plan on answering that question.
First we must look at the definition of Big O. A function f(n) is said to belong to O(g(n)) if and only if f(n) ≤ C*g(n) whenever n >k , where both k and C are constants.
f(n) ≤ C*g(n) whenever n > k
Let’s show log base a of n is Big O of log base b of n, where a> 1 and b > 1. This means b could be any value like 5 , 7, or 89 etc., and same thing goes for a it could be 2,3, 90, or 7 etc.
In order to show this our f(n) = log base a of n and our g(n) = log base b of n. This would give us the following equation.
We can choose values for C and k that would make the above equation true. I will choose C = log base a of b and k = 0. Now our equation will look like the following.
Notice the right hand side of the equation (log base a of b times log base b of n). We can rewrite this equation thanks to the properties of logarithms.
Notice that the right hand side of the equation (log base a of b times log base b of n) is exactly equal to log base a of n which is the value on the left hand side of the equation. So now we get the following equation.
The above equation is always true no matter what the values a, b or n are. Of course a and b must be greater than 1, and n must be greater than 0, so this is why the base doesn’t matter when dealing with Big O asymptotic.
If you would like to learn more about Algorithm Analysis , you can take my online course here. I also have a course on Udemy.com called Recurrence Relation Made Easy where I help students to understand how to solve recurrence relations and asymptotic terms such as Big-O, Big Omega, and Theta. You can check out my YouTube channel of videos where I solve recurrence relations and perform algorithm analysis on code that anyone can check out for free !
Introduction to Algorithm Analysis [For Complete Beginners]
Understand and solve algorithms using Big O, Big Omega, and Theta time complexity.
Recurrence Relation Made Easy | Udemy
A guide to solving any recursion program, or recurrence relation.
Thanks for reading this article I hope its helpful to you all ! Keep up the learning, and if you would like more computer science, programming and algorithm analysis videos please visit and subscribe to my YouTube channels (randerson112358 & compsci112358 )
Check Out the following for content / videos on Computer Science, Algorithm Analysis, Programming and Logic:
Video Tutorials on Recurrence Relation:
Video Tutorial on Algorithm Analysis: