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

I have actually used bubble sort once.

I had a small data set, and, more importantly, I needed a customer who might be a less-than-saavy programmer (VBA) to understand what was going on.

Bubble sort is, if nothing else, simple to understand.



But doesn't VBA have a sort method? I would think a line calling a sort method would be more understandable than a sort you implement.


I deny that. Its may be easy to understand the idea; the code is no more enlightening than any other encoded algorithm. A couple of loops,comparing pairs of objects, triple assignment with a temp - what's that all about? You may be able to explain it/ teach it easier because its smaller, but the code is not transparent.

I'd suggest a recursive algorithm would code up far more transparently. E.g. Sort first half of the list; sort 2nd half of the list; merge the two half-lists. That's obvious at the top level; the details of merge are all that's left to explain. It also demonstrates dissecting a problem into smaller problems, so is a double lesson.




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

Search: