4 ms·
Coding Horror: Everything Is Fast For Small n
- sanj 19y agoI think that the flipside of this article's point is important too: Don't worry about sort algorithms when your n is small. A real example: with social networks, you can make some reasonable assumptions that people will have hundreds, perhaps thousands of 'friends'. For many activities (not DB selects), that's a small value.
- benhoyt 19y agoThen again, even apart from the fact that a qsort() is built into most languages, Quicksort is very nearly as simple to implement as Bubble Sort.
- kcl 19y agoWhen I started reading this article I figured he was going to deliver a lesson on when it's better to fall back to less efficient algorithms when you can be sure of a small n. Territory that's been covered before, sure, but also a topic with a lot of room left for discussion. Instead we get a CS 101 discussion of big-oh? What? Do I really want to take advice from someone whose first instinct was to implement insertion sort? I'll counter: Here's a gem from CS 101 that not everybody's seen: Sorting out Sorting (edit: see the better link posted below) Even if you know algorithms the video is still stylistically interesting. It's a good example of how to teach quantitative material. The YouTube video is speeded up, but the presentation of n^2 sorts is more effective when each of the demos runs for a painfully long two minutes.
- leoc 19y ago"Sorting out Sorting" at normal speed, about 32 minutes long: http://video.google.com/videoplay?docid=3970523862559774879 http://video.google.com/videoplay?docid=3970523862559774879 (Thanks, kcl.)