[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Low-level vs. High-level programming (was My First Computer)



Kevin Lawton wrote:
> 
>        [snip...]            [snip...]            [snip...]
> 
> I'm not too sure how the quicksort in Java works internally. It would not be
> exactly brilliant programming practise to use a bubblesort in C to sort a
> very large number of items. In fact, I don't think it a particularly great
> idea to use a bubblesort to sort large numbers of items in any language. A
> bubblesort is more suited to working on reasonably small numbers of items.
> 
Yes, a bubblesort is suited to working on reasonably small numbers
of items. And a bubblesort is *stable*, meaning that if two records
have the same value for the sort key, those records will *not* be
exchanged. This is important in secondary sorts. 

But bubblesort *can* be suitable for sorting large numbers of
items, *if* you can have some way to guarantee that the list of
items is already *almost* sorted. With only one or two records
out of order in thousand, you might use a bubblesort effectively.

--
+----------------------------------------------------------------+
|   Charles and Francis Richmond     richmond at plano dot net   |
+----------------------------------------------------------------+