

Tell/Show HN: related to the MonkeySort algorithm ... - ColinWright

I originally wrote this as a comment to the submission about the MonkeySort<p>http://news.ycombinator.com/item?id=4131217<p>I initially didn't find that write up very engaging, but then I realised it was actually related to work I did for my PhD, and so I thought I'd share that.<p>The proof that sorting a collection using comparisons requires a minimum of <i>n.log(n)</i> tests is well known. It simply uses the fact that there are <i>n!</i> possible orderings, and any comparison can only eliminate at most half (this is the crucial bit - I'll come back to it).  <i>Log(n!)</i> is about <i>c.n.log(n)</i>, so we might need that many comparisons.  There are algorithms that are guaranteed to achieve that (shell sort, heap sort, <i>etc.</i>) and there are algorithms that usually perform that well and have a smaller constant (quicksort being the canonical example).<p>Fast forward.<p>Suppose we already have some information about the relative orderings of some of our items, and suppose there are now <i>K</i> possible linear orderings.  How many comparisons might we need to make?  The obvious answer is <i>log(K)</i>, but that might not be possible.  It may be that there is no selection of 2 items that lets us eliminate around half the remaining possible linear orderings.<p>Conjecture:  Given a partially ordered set that is not already totally ordered, there exists a pair of elements <i>a</i> and <i>b</i> such that in a randomly chosen linear extension, the probability that <i>a</i> is above <i>b</i> is around 1/2 (in fact between 1/3 and 2/3 inclusive).<p>This means that given partial information, we can always find pairs of elements that eliminate around half (actually at least 1/3) of the remaining possible orderings.  Thus, in theory, we can always sort in comparisons proportional to <i>log(K)</i> where <i>K</i> is the number of possible linear orderings consistent with the knowledge we have.<p>My PhD proved an infinitely large special case of the conjecture, showing that a plausible hiding place for counter-examples does not, in fact, harbor any.<p>Finding such pairs remains an open problem, and, in practice, unless your collection is already nearly totally ordered, it's usually quicker to discard partial information and start "from scratch".
======
ColinWright
Clickable: <http://news.ycombinator.com/item?id=4131217>

