算法分析中 logN 的底数

算法分析中 logN 的底数


参考书:

Data Structures and Algorithm Analysis in C

见:Big O notation Log Base 2 or Log Base 10

What we compare is the relative rates of growth, so it doesn’t matter what is the base of log.

According to the following theorem:
l o g A B = l o g c B l o g C A ;    C > 0 log_A^B = \frac{log_c^B}{log_C^A};\ \ C \gt 0

We can infer that:
l o g 10 N = l o g 2 N l o g 2 10 log_{10}^N = \frac{log_2^N}{log_2^{10}}

Since l o g 2 10 log_2^{10} is a constant, the relative rates of growth of l o g 10 N log_{10}^N and l o g 2 N log_{2}^N is the same.

但是,在数据结构与算法分析 C语言描述这本书中的 logN 默认都是以 2 2 为底数。见书第一章1.2.2:

In computer science, all algorithms are to the base 2 unless specified otherwise.

发布了120 篇原创文章 · 获赞 2 · 访问量 5799

猜你喜欢

转载自blog.csdn.net/Lee567/article/details/103290686