比较两种算法的算法复杂度
comparing Algorithm complexity of two algorithm
在我在这里问这个问题之前,我发现这个网站是问这个问题的合适网站from here
对于同一个问题,我有 2 个算法 Say A 和 B。
A is complexity is = 5nlogn
B is complexity is = n sqrt(n)
我想找到 n0 的值,这样我就可以证明 A 比 B 好。
我尝试了以下方法:
5nlogn/nsqrt(n) = 5logn / sqrt(n)
by putting
n = 512 ==> i got the answer. But i am not sure whether it is correct?
我该怎么做?
要清楚:我想证明以下
A = BigO(B)
不完全是。
您正在寻找
5nlog(n) < nsqrt(n)
5nlog(n) / nsqrt(n) < 1
5log(n) / sqrt(n) < 1
从wolfram alpha开始,这对所有n > ~3500
都是正确的
作为旁注,如果你想显示 5nlog(n)
在 O(nsqrt(n))
中,你可以调整常量,并添加一个常量 C:
5nlog(n) < C*nsqrt(n) for all n > n0
选择C=10
时,以上对所有n>0
都成立
在我在这里问这个问题之前,我发现这个网站是问这个问题的合适网站from here
对于同一个问题,我有 2 个算法 Say A 和 B。
A is complexity is = 5nlogn
B is complexity is = n sqrt(n)
我想找到 n0 的值,这样我就可以证明 A 比 B 好。
我尝试了以下方法:
5nlogn/nsqrt(n) = 5logn / sqrt(n)
by putting
n = 512 ==> i got the answer. But i am not sure whether it is correct?
我该怎么做?
要清楚:我想证明以下
A = BigO(B)
不完全是。
您正在寻找
5nlog(n) < nsqrt(n)
5nlog(n) / nsqrt(n) < 1
5log(n) / sqrt(n) < 1
从wolfram alpha开始,这对所有n > ~3500
作为旁注,如果你想显示 5nlog(n)
在 O(nsqrt(n))
中,你可以调整常量,并添加一个常量 C:
5nlog(n) < C*nsqrt(n) for all n > n0
选择C=10
时,以上对所有n>0