算法的实施例具有不同的最坏情况下的上限,最糟糕的情况下边界和最好情况界限?

编程入门 行业动态 更新时间:2024-10-11 09:24:32
本文介绍了算法的实施例具有不同的最坏情况下的上限,最糟糕的情况下边界和最好情况界限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有没有什么算法,使得用于为一组最坏情况的实例的S,A具有不同的最坏情况的上限和最坏情况下界?此外,它应该有不同的情况下,最好的边界不等于任何最坏情况界限,对一些组输入。

Is there any algorithm A, such that for a set of worst case instances S for A, A has different worst case upper bound and worst case lower bound? Moreover it should have different best case bounds not equal to any worst case bounds,for some set of inputs.

举例说,H是一个假设的算法,使得H具有上限Ο(正^ 3),最坏的情况下下界Ω(N ^ 2)和最好的情况下的运行时间Θ(n)的

For example say H is a hypothetical algorithm such that H has worst case upper bound Ο(n^3), worst case lower bound Ω(n^2) and best case running time Θ(n).

让我知道上述情况实际上是有意义的或不?

Let me know that above situation is actually meaningful or not?

感谢:)

推荐答案

下面的 ^ h 的不太自然,但也许更令人满意的定义。此函数计算输入列表的总和的立方体在一个相当愚蠢的方式

Here's a less natural but perhaps more satisfying definition of H. This function computes the cube of the sum of the input list in a rather silly manner.

def H(lst): s1 = 0 for x in lst: s1 += x if s1 == 0: return 0 elif len(lst) % 2 == 0: s2 = 0 for x in lst: for y in lst: s2 += x * y return s1 * s2 else: s3 = 0 for x in lst: for y in lst: for z in lst: s3 += x * y * z return s3

最好情况下是结合西塔(n)的。最严格的最坏情况上限的形式为O(n ^ K)的为O(n ^ 3)。最严格的最坏情况下界的形式欧米茄(N ^ K)是欧米茄(N ^ 2)。

The best-case bound is Theta(n). The tightest worst-case upper bound of the form O(n^k) is O(n^3). The tightest worst-case lower bound of the form Omega(n^k) is Omega(n^2).

请注意,然而,在紧的绑定的任何形式上的最坏情况是西塔(F(N)),其中f(2米)=平方公尺和f(2M + 1) =立方公尺。

Note, however, that the tightest bound of any form on the worst-case is Theta(f(n)) where f(2m) = m^2 and f(2m+1) = m^3.

更多推荐

算法的实施例具有不同的最坏情况下的上限,最糟糕的情况下边界和最好情况界限?

本文发布于:2023-11-30 22:13:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1651626.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:情况下   上限   边界   界限   算法

发布评论

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

>www.elefans.com

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