Algorithms | Analysis of Algorithms | Question 10

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