算法的复杂性,当面对减法价值 [英] Algorithm complexity when faced with substraction in value

查看:207
本文介绍了算法的复杂性,当面对减法价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的公式,我为了得到我的算法的时间复杂度,简化:(N ^ 2-N)/ 3。是否有应用,可以让我更进一步简化EX pression到一个更普通Θ(N ^ 2)或类似的东西(我假定这就是结果会是,可能是任何规则错误的)。

I have the following formula that I have to simplify in order to get the time complexity of my algorithm : (n^2-n)/3. Are there any rules that apply that can allow me to simplify this expression even further to a more "common" Θ(n^2) or something like that (I'm assuming that's what the result will be, might be wrong).

我根本不知道该如何处理减法这里。通常,如果两个值加对方,只考虑一个是最高的分析算法的复杂度。我该怎么做在这种情况下?

I simply don't know how to deal with the substraction here. Usually, if two values add each other, you only consider the one that is the highest to analyse the complexity of the algorithm. What do I do in this case ?

推荐答案

由于Θ紧约束的,有没有更好的简化的它,如果一些函数 F(N)是无论在Θ(H(N))Θ(G(N))这意味着Θ(H(N))=Θ(G(N)),所以其他功能,你会发现,在信息增益Θ(N ^ 2)在你的例子是没有的。

Since Θ is a tight bound, there is no better simplification for it, if some function f(n) is both in Θ(h(n)) AND in Θ(g(n)) it means that Θ(h(n)) = Θ(g(n)), so for any other function you will find, the information gain over Θ(n^2) in your example is none.

在与减法处理 N R个ķ - N ^ M ,其中 K&GT,M ,你可以简单地扔ñ^ M 走,在分析大Θ表示法。

When dealing with substraction of n^k - n^m, where k>m, you can simply "throw" n^m away, when analyzing big Θ notation.

这是真实的,因为:

n^k - n^m <= n^k  
-> and thus it is in O(n^k)

在另一方面:
M,K 有一定的价值 N ,使得对所有的 N'GT ; N 0.5N ^ K&GT; = N ^ M ,因此:

On the other hand:
For every m,k there is some value N such that for all n>N: 0.5n^k >= n^m, and thus:

n^k - n^m >= n^k - 0.5n^k = 0.5n^k    for n > N
-> it is also in Omega(n^k)

因为我们发现这两个上限和下限,我们可以得出结论 N R个KN ^ M ,当 K&GT,M Θ(N ^ K)
(类似的证明可以用于一般F(N),G(N),其可在不同的Θ-复杂类来完成)。

Since we found both upper and lower bound, we can conclude n^k-n^m, when k>m, is in Θ(n^k).
(Similar proof can be done for general f(n),g(n) which are in different Θ-complexity classes).

这篇关于算法的复杂性,当面对减法价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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