算法的复杂性,当面对减法价值

编程入门 行业动态 更新时间:2024-10-24 11:14:07
本文介绍了算法的复杂性,当面对减法价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下的公式,我为了得到我的算法的时间复杂度,简化:(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).

更多推荐

算法的复杂性,当面对减法价值

本文发布于:2023-11-30 15:05:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1650440.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:减法   复杂性   算法   价值

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!