Go rant

Don nospam at nospam.com
Sat Dec 26 22:24:38 PST 2009


retard wrote:
> Sat, 26 Dec 2009 09:21:55 -0800, Charles Hixson wrote:
> 
>> Denis Koroskin wrote:
>>
>>> On Tue, 22 Dec 2009 00:10:44 +0300, Jérôme M. Berger
>> <jeberger at free.fr>
>>> wrote:
>>>
>>>> Andrei Alexandrescu wrote:
>>>>> Walter Bright wrote:
>>>>>> retard wrote:
>>>>>>> I have several imperative language programming books and instead
>> of
>>>>>>> qsort they introduce the reader to the wonderful world of bubble
>> sort!
>>>>>> Bubble sort should be part of an introductory programming course,
>> if
>>>>>> only because:
>>>>>>
>>>>>> 1. it's an algorithm that gets reinvented if one is not aware of
>> it
>>>>>> 2. one needs to be able to recognize it, as one will encounter it
>> a
>>>>>> lot in production code
>>>>>>
>>>>>> 3. it's a great way to introduce concepts like big O
>>>>>>
>>>>>> 4. it's a great stepping stone to introducing better sorts
>>>>>>
>>>>>>
>>>>>> I've run into bubble sort reimplementations in production code
>> written
>>>>>> by famous programmers who should know better. It happens all the
>> time.
>>>>> Fro your arguments 1-4 and your conclusion, I infer you made a
>> slight
>>>>> typo. Let me fix that for you.
>>>>>
>>>>> s/should be/should not be/
>>>>>
>>>> No, he's right, it should be part of any introductory programming
>>>> course, along with a good explanation of why it is so bad. They say
>>>> that "for every problem there is a solution which is simple, elegant,
>>>> and wrong", and bubble sort is as good a way as any to
>> make
>>>> that point.
>>>>
>>>> However, it is essential that the teacher actually *make* that point
>>>> and not leave the students believing that bubble sort is a good
>>>> algorithm.
>>>>
>>>> Jerome
>>> Bubble sort is not that bad (e.g. a sequence with one element out of
>>> place), it's just niche algorithm.
>> I believe that I was taught that a bubble sort was optimal for lists of
>> fewer than about 25 elements.  I.e., where n is very small, the overhead
>> for the other sorts wasn't worth it.
> 
> Nope, that's big time bs. http://en.wikipedia.org/wiki/
> Bubble_sort#In_practice -- I wasn't even taught bubble sort in school 
> because insertion sort performs much better and is about as easy to 
> comprehend.

I'd say it's easier. If you watch someone sorting some cards, they'll 
use either insertion sort or selection sort. Nobody should have ever 
heard of bubble sort, I'm pleased to hear some schools aren't mentioning 
it. Such a foolish algorithm.

"the bubble sort seems to have nothing to recommend it, except a catchy 
name " - Knuth.



More information about the Digitalmars-d mailing list