Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Coding Horror: Everything Is Fast For Small n (codinghorror.com)
26 points by luccastera on Sept 21, 2007 | hide | past | favorite | 4 comments


When 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.


"Sorting out Sorting" at normal speed, about 32 minutes long: http://video.google.com/videoplay?docid=3970523862559774879 (Thanks, kcl.)


I 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.


Then 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: