HP3000-L Archives

October 2002, Week 1

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Jeff Woods <[log in to unmask]>
Reply To:
Jeff Woods <[log in to unmask]>
Date:
Fri, 4 Oct 2002 22:06:10 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (61 lines)
Michael Berkowitz <[log in to unmask]> wrote:
>Well you could use a COBOL 2002 compliant compiler with a built in bubble
>sort, or use this bubble sort logic I got at
>http://www.softechsolutions.com/techtips/ttipsort.htm

My initial reaction:
"The 2002 COBOL standard includes *bubble* sort?!?"

So I go look at the draft standard and it includes an in-memory/array sort
but (from my cursory exploration) doesn't seem to specify that it's to be
a "bubble sort".  (Whew!)

To quote:
[Knuth1]
It took a good deal of work to analyze the bubble sort; and although the
techniques used in the calculations are instructive, the results are
disappointing since they tell us that the bubble sort isn't really very
good at all. Compared to straight insertion, bubble sorting requires a more
complicated program and takes more than twice as long!

Some of the bubble sort's deficiencies are easy to spot. ....

But none of these refinements lead to an algorithm better than straight
insertion; and we already know that straight insertion isn't suitable for
large N. Another idea is to eliminate most of the exchanges; since most
elements simply shift left one step during an exchange, we could acheive
the same effect by viewing the array differently, shifting the origin of
indexing! But the resulting algorithm is no better than straight
selection....

In short, 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.
[/Knuth1]

And in his summary on sorting:
[Knuth2]
It would be nice if only one or two of the sorting methods would dominate
all of the others, regardless of the application or the computer being
used. But in fact, each method has its own peculiar virtues. For example,
the bubble sort has no apparent redeeming features, since there is always a
better way to do what it does; but even this technique, suitably
generalized, turns out to be useful for two-tape sorting. Thus we find that
nearly all of the algorithms deserve to be remembered, since there are some
applications in which they turn out to be best.
[/Knuth2]

There are many factors that go into choosing an optimal algorithm, but
about bubble sort is only appropriate when it's the only sort algorithm you
know... and even then, insertion sort is easier to code, maintain and
remember.  And Hoare's QuickSort is aptly named when coded well.


[Knuth1] Knuth, Donald E.; The Art of Computer Programming, Volume 3:
Sorting and Searching, 2nd Edition; pp. 109-110

[Knuth2] ibidem, p.380

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2