Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
649 views
in Technique[技术] by (71.8m points)

algorithm - Big O notation Log Base 2 or Log Base 10


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I think it does not matter what is the base of the log as the relative complexity is the same irrespective of the base used.

So you can think of it as O(log2X) = O(log10X)

Also to mention that logarithms are related by some constant.

enter image description here

So

log??(x) = log?(x) / log?(10)

So most of the time we generally disregard constants in complexity analysis, and hence we say that the base doesn't matter.

Also you may find that the base is considered to be 2 most of the time like in Merge Sort. The tree has a height of log? n, since the node has two branches.

1)I am confused over whether is it Log base 10 or Log base 2 as different articles use different bases for their Logarithm .

So as explained above this change of base doesn't matter.

2) Does it make a difference if its Log base 2 or Log base 10??

No it does not matter.

3)Can we assume it mean Log base 10 when we see O(LogN)???

Yes you can assume that provided you know the base conversion rule.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...