25 points ibobev 1 day ago 11 comments
brudgers 18 hours ago | parent
pagade 1 hour ago | parent
pkaye 29 minutes ago | parent
movpasd 1 hour ago | parent
ninju 1 hour ago | parent
https://czep.net/weblog/52cards.html
Anyone know how to determine the age of this page (it's got be at least 20yrs old)
TheRealPomax 34 minutes ago | parent
stronglikedan 28 minutes ago | parent
Dwedit 23 minutes ago | parent
Sharlin 41 minutes ago | parent
1 * 2 * … * n ≤ n * … * n.
(This approximation should be familiar to many from an algorithmics class.)For a tighter bound, use n lg n - n/2, or a better approximation of ln 10 in place of 1/2 if you wish. This comes from Stirling's approximation which notes that
ln n! = n ln n - n + O(ln n).qsort 15 minutes ago | parent
You need both sides though :)
What makes it interesting for estimating algorithmic complexity is that \log{n!} \in \Theta(n \log n). One side is obvious as you note, the other less so, but there's a famous trick to do both at once:
\log{n!} = \log{\prod_{h=0}^{n} h} = \sum_{h=0}^{n} \log{h}
Therefore,
\int_0^n \log{x} dx \le \log{n!} \le \int_0^n \log{x+1} dx
with both integrals trivial by parts.
abetusk 5 minutes ago | parent
As an aside, if you take numbers from 0 to (n-1) in an array, there are n! configurations, so representing each configuration or differentiating each configuration take n lg n bits. So, in some sense, taking a mapping that's able to differentiate the input state to map to the ordered state takes at least O(n lg n) time, the standard runtime of a basic sorting algorithm.
Any additional assumptions (n larger than maximum element, distribution of elements) helps reduce this.