2
$\begingroup$

Is there any sorting algorithm that takes order of $\log n!$ in the worst case? I know that this is the lower bound for sorting algorithms using comparison based sorting. I know that there are algorithms of order $n\log n,ドル but since $n!$ grows much slower than $n^n,ドル I wish to know of there is any algorithm of this order.

Raphael
73.3k31 gold badges183 silver badges403 bronze badges
asked May 21, 2014 at 11:03
$\endgroup$
4
  • 1
    $\begingroup$ Mergesort will do. $\endgroup$ Commented May 21, 2014 at 11:42
  • $\begingroup$ Follow-up question: is there a comparison sorting algorithm having comparison depth $\lceil \log_2 n! \rceil$? (Assume for simplicity that the input elements are distinct.) $\endgroup$ Commented May 21, 2014 at 18:03
  • 1
    $\begingroup$ @YuvalFilmus I believe it's known that the 'precise' bound can't be achieved for all values of $n$; as noted in cstheory.stackexchange.com/questions/21152/… , TAOCP has some discussion of this topic. $\endgroup$ Commented May 21, 2014 at 19:48
  • $\begingroup$ $n!$ grows a little slower than $n^n,ドル but $\log(n!)$ and $\log(n^n)$ are asymptotically equivalent. $\endgroup$ Commented Nov 27, 2015 at 13:09

1 Answer 1

7
$\begingroup$

By Stirling's approximation, $$\log(n!) = n\log n - n + O(\log n) = \Theta(n\log n),,円$$ so, yes, there are lots of sorting algorithms that run in time $O(\log(n!))$.

answered May 21, 2014 at 13:22
$\endgroup$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.