Why aren't we all speaking LISP now?
tdelaney at avaya.com
Fri May 11 02:14:40 EDT 2001
> >Indeed, the point of teaching bubblesort is to teach *not to use*
> I would have said "...to teach WHEN not to use bubblesort."
> There have
> been many times I needed to sort a list in some throaway
> utility when I
> knew the list was going to be limited in size. I KNOW I can write a
> bubblesort or insertion sort and get it right. I'd have to
> look up and debug a quicksort or a heapsort.
You can always write an insertion sort and get it right. You can always
write a bubble sort and get it right. The code is very similar in length.
Conceptually, an insertion sort is more logical (despite this, *everyone*
I've known, including myself, wrote a bubble sort as their first ever sort -
I wonder why?).
Given these facts, you still should *not* use a bubble sort, as a insertion
sort is much more efficient.
Nonetheless, I concede the point. *When* not to use a bubble sort, which is
any time you remember that an insertion or better sort exists.
More information about the Python-list