Re: Bubble Sort in C



On 15 Sep, 05:29, arnuld <arnuld.miz...@xxxxxxxxx> wrote:
On Sep 15, 6:37 am, user923005 <dcor...@xxxxxxxxx> wrote:

Writing a better bubble sort is about as valuable as polishing a Yak.
Sure, once in a while there may be a "Who's got the shiniest Yak"
contest, but how often do the masses experience such a contest?

I'm not sure I agree with this

You are saying that the exercise I did was purely academic (not
practical).

writing almost *any* code when you are learnign is "practical".
I don't need a farenheit to centigrade converter program (I have
a table next to my heating controls) but it's still a useful
excercise in K&R. I don't understand why "academic" is used
as a synonym for "useless".


Remember I am not student anymore

well I am. I'm still learnign things and I don't plan to stop.
I *graduated* yonks ago.


<snip>

I am not thrashing you. I have academic exercises which theoretical to
the point of totally unrelated to the real world programming.  So, if
you think my ways of learning algorithms are not practical, you must
have something better to offer.

well you have chosen a rather poor algorithm to play with.
I'm not sure reinventing wheels like this is going to teach you much.
Get a decent book on algorithms. Sedgewick (or if brave, Knuth)
they'll explain the various trade-offs the algorithms exhibit.

Bubble sort is so bad that I think it a terrible disservice that it is
a common choice in algorithms teaching courses, even though insertion
sort is easily just as simple and far more effective.  Now, if bubble
sort is taught in an algorithms course as an example of "Don't do it
this way!" then I have no objection to its inclusion.

If other regular posters say that Bubble-Sort is inherently bad idea
(except of the 2 cases you mention in an earlier reply) then I will
not use in the code I write for my employer. BTW, next algorithm in
Ullman's book is insertion sort :)

Bubble sort is bad. For small numbers of elements Insertion Sort beats
it
and for large numbers of elements Quick Sort beats it. Insertion Sort
is simpler to code.

"the bubble sort seems to have nothing to recommend it, except a
catchy name and the fact that it leads to some interesting
theoretical
problems" D.E.Knuth


.



Relevant Pages

  • Re: Whats the best language to learn...
    ... Aren't you confusing insertion sort with merge sort here? ... The basic bubble sort *always* requires n-1 passes through the array ...
    (comp.programming)
  • Re: insertion sort in C
    ... One thing I don't get is how it is less expansive than bubble sort, ... insertion sort routine, but a highly modified bubble sort. ... improved by exiting the loop once the data swaps end. ...
    (comp.lang.c)
  • Re: Bubble Sort in C
    ... Writing a better bubble sort is about as valuable as polishing a Yak. ... a common choice in algorithms teaching courses, ... Ullman's book is insertion sort:) ...
    (comp.lang.c)
  • Re: hc11 program help
    ... >became an ordinary bubble sort. ... It's really very well known and documented under the name "Shell ... but insertion sort requires ...
    (comp.arch.embedded)
  • Re: Are DSP Processors losing out to ARMs?
    ... of insertion sort, bubble sort, quick sort and whatever ... other algorithms were available. ... you let insertion sort (or whatever the optimum algorithm ...
    (comp.dsp)