3 ms·
> The only way to prevent this, randomly sorting every unsorted collection you export, isn't feasible to reliably maintain. It's feasible to maintain. But peo
by eru 14y ago
> The only way to prevent this, randomly sorting every unsorted collection you export, isn't feasible to reliably maintain.
It's feasible to maintain. But people might rely on it, too. As a random example (and easily avoidable example), quicksort works with random input, but 'breaks' for pre-sorted input.
- dpark 14y agoThat depends on the pivot chosen. If your quicksort implementation actually hits n^2 behavior with sorted input, it's probably not the best implementation. Any implementation can hit n^2 with random input. It's just highly unlikely.
- eru 14y agoYes, I know. That's what the "easily avoidable" was for. I couldn't think of a better example in a few minutes, but if something can go wrong, I am sure it will eventually go wrong.