简体   繁体   English

如何显示5n = O(nlogn)

[英]how to show that 5n=O(nlogn)

I have this as a homework question and don't remember learning it in class. 我把它作为一个家庭作业问题,不记得在课堂上学习。 Can someone point me in the right direction or have documentation on how to solve these types of problems? 有人可以指出我正确的方向或有关于如何解决这些类型的问题的文件?

More formally... 更正式的......

First, we prove that if f(n) = 5n , then f ∈ O(n) . 首先,我们证明如果f(n) = 5n ,则f ∈ O(n) In order to show this, we must show that for some sufficiently large k and i ≥ k , f(i) ≤ ci . 为了证明这一点,我们必须证明,对于一些足够大的ki ≥ kf(i) ≤ ci Fortunately, c = 5 makes this trivial. 幸运的是, c = 5使这个变得微不足道。

Next, I'll prove that for all f ∈ O(n) that f ∈ O(n * log n) . 接下来,我将证明对于所有f ∈ O(n) f ∈ O(n * log n) Hence, we must show that for some sufficiently large k , all i ≥ k , f(i) ≤ ci * log i . 因此,我们必须证明,对于一些足够大的k ,所有i ≥ kf(i) ≤ ci * log i Hence, if we let k be large enough that f(i) ≤ ci , and i ≥ 2 , then the result is trivial since ci ≤ ci * log i . 因此,如果我们让k足够大,使得f(i) ≤ ci ,并且i ≥ 2 ,那么结果是微不足道的,因为ci ≤ ci * log i

QED. QED。

Look into the definition of big-O-notation. 查看big-O-notation的定义。 It means that 5n will run no slower the nlogn, which is true. 这意味着5n将不会慢慢运行nlogn,这是真的。 nlogn is an upper bound of the number of operations to be performed. nlogn是要执行的操作数的上限。

I don't remember the wording of the formal definition, but what you have to show is: 我不记得正式定义的措辞,但你必须展示的是:

c 1 * 5 * n < c 2 * n * logn, n>c 3 c 1 * 5 * n <c 2 * n * logn,n> c 3

where c 1 and c 2 are arbitrary constants, for some number c 3 . 其中c 1和c 2是任意常数,对于某些数字c 3 Define c 3 in terms of c 1 and c 2 , and you're done. 根据c 1和c 2定义c 3 ,你就完成了。

It's been three years since I touched big-O stuff. 我触及big-O之后已经三年了。 But I think you can try to show this: 但我认为你可以试着证明这一点:

O(5n) = O(n) = O(nlogn) O(5n)= O(n)= O(nlogn)

O(5n) = O(n) is very easy to show, so all you have to do now is to show O(n) = O(nlogn) which shouldn't be too hard too. O(5n)= O(n)很容易显示,所以你现在要做的就是显示O(n)= O(nlogn),这也不应该太难。

You can prove it by applying L'Hopitals rule to lim n-> infinity of 5n/nlogn 您可以通过将L'Hopitals规则应用于5n / nlogn的limn-> infinity来证明它

g(n) = 5n and f(n)=nlogn g(n)= 5n且f(n)= nlogn

Derivate g(n) and f(n) so you will get something like this 导出g(n)和f(n),这样你就会得到这样的东西

5/(some stuff here that will contain n) 5 /(这里包含n的一些东西)

5/infinity = 0 so 5n = O(nlogn) is true 5 / infinity = 0所以5n = O(nlogn)为真

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

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