2
$\begingroup$

I've been recently asked by one of my friends to prove an equation but still, I'm confused how to get it started tho.

log(n!)= θ(nlog(n))

Does anyone know how to help? I'll be very grateful if someone comes to reply to my issue.

Thanks in advance.

$\endgroup$
  • 1
    $\begingroup$ $\log(n!)=\sum_{k=1}^n\log{k}$ Use a Riemann sum. $\endgroup$ – saulspatz Feb 3 at 13:20
  • $\begingroup$ And now you just go for a worst case scenario, so you estimate every term by the upper bound $\log(n)$ $\endgroup$ – Wesley Strik Feb 3 at 13:23
1
$\begingroup$

$$O(\log{(n!)})$$$$=O(\log{(n(n-1)(n-2)...(2)(1))})$$$$=O(\log{(n)}+\log{(n-1)}+\log{(n-2)}+...+\log{(2)}+\log{(1)})$$$$=O(n\log{(n))}$$ As $n$ logarithms are added, we have a worst case time complexity of $O(n\log{(n))}$.

$\endgroup$
  • $\begingroup$ Thank you, sir. $\endgroup$ – Miller Feb 3 at 13:24
  • $\begingroup$ Will you accept my answer? $\endgroup$ – Peter Foreman Feb 3 at 13:25
  • $\begingroup$ Yes, surely. Thanks again. $\endgroup$ – Miller Feb 3 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.