Prove that n! = O(n^n)

耗尽温柔 提交于 2020-01-01 12:01:22

问题


How can I prove that n! = O(n^n)?


回答1:


I assume that you want to prove that the function n! is an element of the set O(n^n). This can be proven quite easily:

Definition: A function f(n) is element of the set O(g(n)) if there exists a c>0 such that there exists a m such that for all k>m we have that f(k)<=c*g(k).

So, we have to compare n! against n^n. Let's write them one under another:

n!  = n * (n-1) * (n-2) * (n-3) * ... * 3 * 2 * 1
n^n = n *  n    *  n    *  n    * ... * n * n * n

As you can see, the first line (n!) and the second line (n^n) have both exactly n items on the right side. If we compare these items, we see that every item is at most as large as it's corresponding item in the second line. Thus n! <= n^n (at least for n>5).

So, we can - look at the definition - say, that there exists c=1 such that there exists m=5 such that for all k>5 we have that k! < k^k, which proves that n! is indeed an element of O(n^n).



来源:https://stackoverflow.com/questions/4999448/prove-that-n-onn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!