Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Several years ago, I had an exam question asking what sort algorithm one should use in different situations, one of which was "automatically sorting a bibliography list when printing a research paper". I answered that while bubble sort is normally terrible, it's a great choice here if you're hand-rolling a sort instead of using a library. The data set couldn't possibly be large enough for the sort run-time to matter, particularly in comparison to printing time, and it's the simplest to correctly program.

There are circumstances in which bubble sort really is that bad, but on small data sets that are already disk/network/peripheral IO bound, it's just fine.



I'm curious how that answer went over with your teacher.


She hated it. I managed to salvage full credit by saying "but the answer you were looking for was insertion sort."




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

Search: