If g(n) = sqrt(n)^sqrt(n), does the complexity of g(n) = O(2^n)?

浪尽此生 提交于 2020-01-02 03:26:08

问题


If g(n) = sqrt(n)sqrt(n), does the complexity of g(n) = O(2n)?

Any help is appreciated.


回答1:


A useful technique when comparing two exponential functions is to get them to have the same base:

√n√n = (2lg √n)√n = 2√n lg √n

Now you're comparing 2√n lg √n against 2n, and hopefully from that it's easy to see that the former function does not grow as rapidly as the latter, so √n√n = O(2n) is indeed true.




回答2:


The other proofs are short and nice, but here is more detailed proof going to the definitions of the big-oh notations and the computation of the needed limits.

A function g(n) is upper-bounded by another function f(n) by the big-Oh notation (g(n) = O(f(n))) if it holds that (source)

Put in the functions and we must compute

First some algebraic massage on the g(n) term. By the root-identities, it holds that sqrt(n) = n^(1/2). Furthermore it holds that (x^a)^b = x^(a*b). With that:

Furthermore, 2^n is exp(log( 2^n )) by the logarithmic identities, and then log(a^b) = b*log(a) we have 2^n = exp(log( 2^n )) = exp(n * log(2)). The same can be applied to n^(1/2 sqrt(n)), it becomes exp(log( n^(1/2 sqrt(n)) = exp(1/2*sqrt(n)*log(n)). So now we have

At this point we can compare the growth of the exponents, i.e. compare

That limit is 0 because const * n grows faster than sqrt(n)*log(n). This can in turn be shown the calculating the limit explicitly. Put the 1/2 and the log2 in the denumerator. Since n = sqrt(n) * sqrt(n), we can simplify it to:

This limit is indeed zero, because the squareroot grows faster than logarithm by the Orders of common functions. Thus the exponent of the lower function grows faster than the exponent of the upper function. Thus g(n) = O(2^n) is rigorously proven by the first theorem.




回答3:


One can assume O(log n) < O(sqrt(n)) (Order of common functions - wikipedia)

The transformation works as follows:

sqrt(n)^sqrt(n)                2^n              # a^b = e^(ln(a) * b)
e^(ln(sqrt(n)) * sqrt(n))      e^(ln(2) * n)    # if e^a < e^b, then a < b
ln(sqrt(n)) * sqrt(n)          ln(2) * n        # / sqrt(n)
ln(sqrt(n))                    ln(2) * sqrt(n)  # ln(a^b) = b * ln(a)
0.5 ln(n)                      ln(2) * sqrt(n)  # ln(a) / ln(b) = log(a base b)
0.5 log(n base 2)              sqrt(n)          # base and constant factor don't matter
log(n)                         sqrt(n)

I've omitted complexity-classes for simplicity. The above should be read bottom to top for a proper proof.



来源:https://stackoverflow.com/questions/42601876/if-gn-sqrtnsqrtn-does-the-complexity-of-gn-o2n

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