theta符号_大Theta和渐近符号的解释

大Theta符号(Θ)用于表示算法运行时间的精确界限,当一个算法的最好和最坏情况运行时间相同,它给出了算法的平均运行时间。文章介绍了大O、大Omega和大Theta在渐近表示法中的意义,并通过实例说明如何理解和使用大Theta。
摘要由CSDN通过智能技术生成

theta符号

Big Omega tells us the lower bound of the runtime of a function, and Big O tells us the upper bound.

Big Omega告诉我们函数运行时的下限,Big O告诉我们上限。

Often times, they are different and we can’t put a guarantee on the runtime - it will vary between the two bounds and the inputs. But what happens when they’re the same? Then we can give a theta (Θ) bound - our function will run in that time, no matter what input we give it.

通常,它们是不同的,我们不能保证运行时-它在两个范围和输入之间会有所不同。 但是,当它们相同时会发生什么呢? 然后,我们可以给定theta (θ)界限-无论我们给它什么输入,我们的函数都会在那个时候运行。

In general, we always want to give a theta bound if possible because it is the most accurate and tightest bound. If we can’t give a theta bound, the next best thing is the tightest O bound possible.

通常,如果可能的话,我们总是希望给出theta界限,因为它是最准确,最严格的界限。 如果我们不能给定theta界限,那么下一个最好的事情就是尽可能严格的O界限。

Take, for example, a function that searches an array for the value 0:

以一个在数组中搜索值0的函数为例:

def containsZero(arr): #assume normal array of length n with no edge cases
  for num x in arr:
    if x == 0:
       return true
  return false
  1. What’s the best case? Well, if the array we give it has 0 as the first value, it will take constan
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值