9 comments

[ 2.6 ms ] story [ 34.2 ms ] thread
This is an interesting motivation, but the algorithm itself isn't particularly novel -- it's more or less a Quick sort with a really bad way of selecting pivots.
Yes and no...it does use a pivot, true, but is a bit more distinct than just that. For one thing, it is iterative where quicksort is recursive, so it doesn't need any external storage for a stack.
This assumes the man decides. If you truly confine the joint agreement to one decision maker, you could drastically alter what goes into a man making his decision.

A factor of equality exponentially complicates this hypothesis.

How does this algorithm perform when processor cache is considered?

Upon first glance it seems that it might perform really well with N = cache_line_size / sizeof(T) so perhaps N = 16 for sorting ints?

What size array would be optimal for N = 16?

I think you may have misunderstood how the algorithm works. N is simply the number of items remaining in the working set, so over the course of the algorithm N goes from n to 0.

You might be thinking of when √n - 1 = 16, (i.e. the maximum size of the initial length the pivot is picked from is 16). In that case, n = 17*17, or 289.

Does that help?

Wouldn't a marriage sort compare different keys as time went on? It would start sorting on "hair color" at the start, then "wants kids" towards the end?

;)