How to efficiently sort socks JAN 22 2013
From Stack Overflow, a question about how to efficient sort a pile of socks.
Yesterday I was pairing the socks from the clean laundry, and figured out the way I was doing it is not very efficient. I was doing a naive search -- picking one sock and "iterating" the pile in order to find its pair. This requires iterating over n/2 * n/4 = n^2/8 socks on average.
As a computer scientist I was thinking what I could do? sorting (according to size/color/...) of course came into mind to achieve O(NlogN) solution.
And everyone gets it wrong. The correct answer is actually:
1) Throw all your socks out.
2) Go to Uniqlo and buy 15 identical pairs of black socks.
3) When you want to wear socks, pick any two out of the drawer.
4) When you notice your socks are wearing out, goto step 1.
Of course, it was Socks, and not Stocks, and I smiled amusedly at my brain's sloppy shortcuts. But upon reflection, given the increasingly short half-life of most quantitative or systematic strategies, the post might just as well have been describing investment strategies, their allocators, and how they are seemingly implemented:
1) Throw out all your old stocks (or underperforming portfolio managers).
2) Go to Clarifi, Tradestation or your data-miner of choice and rank all potential strategies. (or to save time, or if you're a cloner, rank all stocks by something resembling their active weight presence in the portfolios of top-performing hedge funds based on 13F-HRs and intermediate filings)
3) When you need new stocks, pick the top 5 performing strategies, or the aggregate high-conviction clone portfolio
4) When you notice your Stocks are wearing out or your strategy returns decaying, goto step 1.
This is not a lament, nor a mean-spirited poke at cloners, though it highlights the potential, increasingly severe, feedback effects, more fundamentally-oriented practitioners must navigate.