Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #31654
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Martin Gregorie <martin@address-in-sig.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements |
| Date | Fri, 8 May 2015 20:42:47 +0000 (UTC) |
| Organization | A noiseless patient Spider |
| Lines | 25 |
| Message-ID | <mij747$nrq$1@dont-email.me> (permalink) |
| References | <c26476e6-86b7-494b-a2e8-4d9eb7f7bbd7@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Fri, 8 May 2015 20:42:47 +0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="24442"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX194CX52Ir3BEbClOeEJ9ov6NiovPTfLdq4=" |
| User-Agent | Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) |
| Cancel-Lock | sha1:8A9VJPw/Xh/7FOj0Y9qLXEwlY64= |
| Xref | csiph.com comp.lang.java.programmer:31654 |
Show key headers only | View raw
On Mon, 04 May 2015 10:39:26 -0700, Ajay Paul wrote: > what are the best and worst sorting algorithm for 1 to 10,000 and then > 10,000 + elements. > > I understand that bubble short is worst. The relative cost of the key comparison and element swap steps is important. Some will tell you that quicksort is significantly faster than shell-sort without qualifying that statement but that it only true if key comparison has a lower cost than swapping elements: if key comparison is expensive, i.e. there are multiple keys in each item and each key comparison is expensive (such as caseless comparisons) then quicksort becomes the slower algorithm because it minimises element swaps on the assumption that key comparison is always cheaper than swapping items. Bottom line: as others have said, use the standard Collection sorts unless properly instrumented tests show their (lack of) performance is causing problems. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Ajay Paul <ajaykpaul@gmail.com> - 2015-05-04 10:39 -0700
Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Marcel Mueller <news.5.maazl@spamgourmet.org> - 2015-05-04 19:54 +0200
Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-05-09 07:58 -0400
Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-05-04 14:16 -0400
Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-05-04 14:27 -0400
Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Martin Gregorie <martin@address-in-sig.invalid> - 2015-05-08 20:42 +0000
Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements v_borchert@despammed.com (Volker Borchert) - 2015-05-11 02:32 +0000
Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Gene Wirchenko <genew@telus.net> - 2015-05-11 14:00 -0700
Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-05-11 17:27 -0400
Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements Arne Vajhøj <arne@vajhoej.dk> - 2015-06-03 21:53 -0400
csiph-web