Skip to content
Related Articles

Related Articles

Algorithms | Analysis of Algorithms | Question 10

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 13 Feb, 2013

The following statement is valid.

log(n!) = \theta(n log n).
(A) True
(B) False

Answer: (A)

Explanation: Order of growth of \log n! and n\log n is same for large values of n, i.e., \theta (\log n!) = \theta (n\log n). So time complexity of fun() is  \theta (n\log n).

The expression \theta (\log n!) = \theta (n\log n) can be easily derived from following Stirling’s approximation (or Stirling’s formula).

 \log n! = n\log n - n +O(\log(n))\

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!