为O(log n)的总是快于O(N) [英] Is O(log n) always faster than O(n)

查看:148
本文介绍了为O(log n)的总是快于O(N)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果有2个algorthims计算相同的结果,不同的复杂性,将O(log n)的永远是更快?如果是的话,请解释一下。顺便说一句,这不是一个问题分配

If there are 2 algorthims that calculate the same result with different complexities, will O(log n) always be faster? If so please explain. BTW this is not an assignment question.

推荐答案

没有。如果一种算法的运行N / 100 ,另一个在(日志N)* 100 ,然后第二个会慢一些较小的投入规模。渐近复杂性是关于运行时间行为作为输入尺寸去到无穷大。

No. If one algorithm runs in N/100 and the other one in (log N)*100, then the second one will be slower for smaller input sizes. Asymptotic complexities are about the behavior of the running time as the input sizes go to infinity.

这篇关于为O(log n)的总是快于O(N)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆