开发者

What is the base of the logarithm for the purposes of Algorithms?

开发者 https://www.devze.com 2022-12-11 06:18 出处:网络
While cons开发者_开发百科idering O(log(N)) for time complexity, what is the base of log?All logarithms are related by some constant. (Hence the change-of-base formula). Because we generally disregard

While cons开发者_开发百科idering O(log(N)) for time complexity, what is the base of log?


All logarithms are related by some constant. (Hence the change-of-base formula). Because we generally disregard constants in complexity analysis, the base doesn't matter.

Usually, the base is considered to be 2, when deriving the algorithm. Consider a sort like merge sort. You can construct a tree out of it, and the tree has a height of log₂ n, because each node has two branches.


It doesn't matter, the relative complexity is the same regardless of the base used.


One way to think of it is that O(log2X) = O(log10X) = O(logNX)

0

精彩评论

暂无评论...
验证码 换一张
取 消