What is the base of logarithm on all time-complexity algorithms? Is it base 10 or base e?
When we say that the average sorting complexity is O(n log n). Is the base of log n 10 or e?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In Computer Science, it’s often base 2. This is because many divide and conquer algorithms that exhibit this kind of complexity are dividing the problem in two at each step.
Binary search is a classic example. At each step, we divide the array into two and only recursively search in one of the halves, until you reach a base case of a subarray of one element (or zero elements). When dividing an array of length
nin two, the total number of divisions before reaching a one element array islog2(n).This is often simplified because the logarithms of different bases are effectively equivalent when discussing algorithm analysis.