简体   繁体   English

大欧米茄和大西塔

[英]Big Omega and Big Theta

A function like f(n)=3n^2+2 is O(n^2) because n^2 is the biggest exponent in the function.f(n)=3n^2+2这样的函数是 O(n^2) 因为 n^2 是函数中的最大指数。 However, the function 1f(n)= n^31 is not O(n^2) because the biggest exponent is 3, not 2.但是,函数 1f(n)= n^31不是O(n^2)因为最大指数是 3,而不是 2。

So in order to make a guess like this on Big Omega or Big Theta, what should we look for in the function?那么为了对 Big Omega 或 Big Theta 进行这样的猜测,我们应该在函数中寻找什么? Can we do something analogous to what we did for Big O notation above?我们可以做一些类似于我们在上面对 Big O 表示法所做的事情吗?

For example, let's say the questions asks us to find the Big Omega or Big Theta of the function f(n)= 3n^2 +1 .例如,假设问题要求我们找到函数f(n)= 3n^2 +1的 Big Omega 或 Big Theta。 Is f(n)= O(n) , Big Omega(n) or a Big Theta(n) ? f(n)= O(n)Big Omega(n)还是Big Theta(n) If I am about to take an educated guess on whether this function is Big O(n), I would say no (because the biggest exponent of the function is 2, not 1).如果我要对这个函数是否是大 O(n) 进行有根据的猜测,我会说不是(因为该函数的最大指数是 2,而不是 1)。 I would prove this more formally using induction.我将使用归纳法更正式地证明这一点。

So, can we do something analogous to what we did with Big O notation in the first example?那么,我们可以做一些类似于我们在第一个示例中使用 Big O 表示法所做的事情吗? What should I look for in the function to guess what the Big Omega and Theta will be, and to determine if the "educated guess" is correct?我应该在函数中寻找什么来猜测 Big Omega 和 Theta 是什么,并确定“有根据的猜测”是否正确?

Your example uses polynomials, so I will assume that.你的例子使用多项式,所以我会假设。

  • your polynomial is O(n^k) if k is greater than or equal to the order of your polynomial.如果 k 大于或等于多项式的阶,则多项式为 O(n^k)。

  • your polynomial is Omega(n^k) if k is less than or equal to the order of your polynomial.如果 k 小于或等于多项式的阶数,则多项式为 Omega(n^k)。

  • your polynomial is Theta(n^k) if it is both O(n^k) and Omega(n^k).你的多项式是 Theta(n^k) 如果它同时是 O(n^k) 和 Omega(n^k)。

So, can we do something analogous to what we did with Big O notation in the first example?那么,我们可以做一些类似于我们在第一个示例中使用 Big O 表示法所做的事情吗?

If you're looking for something that allows you to eyeball if something is Big Omega, Big O, or Big Theta for polynomials, you can use the Theorem of Polynomial Orders (pretty much what Patrick87 said).如果您正在寻找可以让您注意多项式的 Big Omega、Big O 或 Big Theta 的东西,您可以使用多项式阶定理(几乎是 Patrick87 所说的)。

Basically, the Theorem of Polynomial Orders allows you to solely look at the highest order term and use that as your desired bound for Big O, Big Omega, and Big Theta.基本上,多项式阶定理允许您只查看最高阶项,并将其用作您想要的 Big O、Big Omega 和 Big Theta 的界限。

What should I look for in the function to guess what the Big Omega and Theta will be, and to determine if the "educated guess" is correct?我应该在函数中寻找什么来猜测 Big Omega 和 Theta 是什么,并确定“有根据的猜测”是否正确?

Ideally, your function would be a polynomial as that would make it the problem much simpler.理想情况下,您的函数将是多项式,因为这会使问题变得更简单。 But, it can also be a logarithmic function or an exponential function.但是,它也可以是对数函数或指数函数。

To determine if the "educated guess" is correct, you have to first understand what kind of runtime you are looking for.要确定“有根据的猜测”是否正确,您必须首先了解您正在寻找什么样的运行时。 Ask yourself: am I looking for the worst case running time for this algorithm?问问自己:我是否正在寻找该算法的最坏情况运行时间? or am I looking for the best case running time for this algorithm?还是我正在寻找该算法的最佳案例运行时间? or am I looking for the general running time of the algorithm?还是我在寻找算法的一般运行时间?

If you are looking at the worst-case running time of the algorithm, you can simply prove Big Omega using the theorem of polynomial order (if it's a polynomial function) or through an example.如果您正在查看算法的最坏情况运行时间,您可以简单地使用多项式阶定理(如果它是多项式函数)或通过示例来证明 Big Omega。 However, you must analyze the algorithm to be able to prove Big O and Big Theta.但是,您必须分析算法才能证明 Big O 和 Big Theta。

If you are looking at the best-case running time of the algorithm, you can prove Big O using an example or through the theorem of polynomial order (if it's a polynomial).如果您正在查看算法的最佳运行时间,您可以使用示例或通过多项式阶定理(如果它是多项式)来证明 Big O。 However, Big Omega and Big Theta can only be proved by analyzing the algorithm.但是,Big Omega 和 Big Theta 只能通过分析算法来证明。

Basically, you can only prove the least informative bounds for best-case running time and worst-case running time of the algorithm with an example.基本上,您只能通过示例证明算法的最佳情况运行时间和最坏情况运行时间的信息最少的界限。

For proving the general running time of an algorithm, you have to make sure that the function for the algorithm's running time you have been given is for all input - a single example is not sufficient in this case.为了证明算法的一般运行时间,您必须确保为您提供的算法运行时间函数适用于所有输入 - 在这种情况下,单个示例是不够的。 When you don't have a function for all input, you have to analyze the algorithm to prove any of the three (Big O, Big Omega, Big Theta) for all inputs for the algorithm.当您没有所有输入的函数时,您必须分析算法以证明算法的所有输入的三个(Big O、Big Omega、Big Theta)中的任何一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM