However, all the sorts lose very badly to the linear solutions.
Yeah... that's expected, of course. And the longer the list gets, the worse the beating the O(n) solutions will give to the O(n log n) sorts too. That's the important fact because, sometimes with small datasets, benchmarks will show the worse algorithm outperforming the better one. But, when the datasets get larger, the better algorithm inevitably wins. The moral being that analysis is better than benchmarking.
-sauoq "My two cents aren't worth a dime.";
In reply to Re^6: Finding the Shortest Element in an Array
by sauoq
in thread Finding the Shortest Element in an Array
by awohld
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |