Re: Help me with references
- From: Eric Sosman <eric.sosman@xxxxxxx>
- Date: Mon, 15 Aug 2005 16:07:07 -0400
Oliver Wong wrote:
> "Kenneth P. Turvey" <kt@xxxxxxxxxxxxxxxxxx> wrote in message
> news:erp6t2-etl.ln1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
>>If this is just a learning exercise then that's great, but if you really
>>want to sort something there really isn't ever a good use for bubble sort.
>>You should probably let Java do the sorting for you unless you have a
>>reason to use a specific algorithm. That algorithm will never be bubble
>>sort.
>
> Bubblesort is O(n^2) and Mergesort is O(n log(n)), but the O(n^2) in
> BubbleSort has a small constant.
Bigger than the n^2 coefficient of either straight selection
or straight insertion, though -- at least, on every machine I've
ever heard of. (Make that "every general-purpose computer."
Knuth shows that bubble sort and straight insertion are equivalent
in a network of comparators that can work in parallel; he also
cites Demuth's proof that bubble sort is optimal for a machine
with a cyclic "rotating drum" external memory and only enough
internal memory for one record.)
> A clever sorting algorithm might use
> Mergesort of Quicksort if the size of the set is greater than 10 elements,
> but use BubbleSort if it's smaller than 10 elements, for example.
It doesn't make sense to ride a jetliner from door to door;
agreed. It also doesn't make sense to ride to the airport on
a backhoe and come home on a bulldozer.
--
Eric.Sosman@xxxxxxx
.
- References:
- Help me with references
- From: Masamunexiii
- Re: Help me with references
- From: Kenneth P. Turvey
- Re: Help me with references
- From: Oliver Wong
- Help me with references
- Prev by Date: Re: JRE and Browser Plugin Problems
- Next by Date: Re: JRE and Browser Plugin Problems
- Previous by thread: Re: Help me with references
- Next by thread: Re: Help me with references
- Index(es):
Relevant Pages
|