Preface
Whether it is a computer algorithm introduction, or data structure book, the time complexity of the algorithm is used to include O (LOGN) Such a description, but did not explicitly say Logn the base is how much. The time complexity of the log level in the algorithm is due to the use of divide-and-conquer thought, which is directly determined by the complexity of the division. If the dichotomy is used, then 2 will be the base, and the third method will be based on 3, and so on.
But whatever the base is, the incremental meaning of the log level is the same. In other words, the time complexity of the algorithm increases with the number of processing data growth relationship is the same.
We first consider O (LOGX (n)) and O (logy (n)), x!=y, we are considering the situation where N tends to infinity. When n tends to infinity, the limit of LOGX (n)/logy (n) can be found, the limit equals LNY/LNX, which is a constant, that is, when n tends to infinity, these two things are only one constant. So from the perspective of the algorithm, the base of log is not important. Finally, combining the above, I also say about the definition of Big O (algorithm introduction 28 page definition), pay attention to this definition and advanced mathematics in the limits of the comparison, it is obvious that the definition here is embodied a limit of thought, assuming we will n0 take a very large number, obviously, when N is greater than N0, We can find that a logarithmic function of any base is actually a constant number of times. So the book says O (logn) can already express the logarithm of all the bases, just like O (n^2). There is no very strict proof, but I think it is better to understand that, if there is an interest to prove, can refer to the high number of the limit tends to infinity proof.
From: "The sword means offer"
if the algorithm's
T(
n) =
O (log n), it is said to have a
logarithmic time . Since computers use binary notation systems, logarithms are often based on 10 (i.e. log10
n, sometimes writing LG
N). However, by a logarithmic commutation formula, Loga
n and logb
n have only one constant factor, and this factor is discarded in the large O notation.
so it is recorded as O (log n), regardless of the base of the logarithm, is the standard notation of the logarithmic time algorithm. From : Know
What is the O (Logn) base in algorithmic complexity?