Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Using Java Classes to Sort a Small Array Quickly Date: Fri, 16 Sep 2011 21:03:00 -0400 Organization: A noiseless patient Spider Lines: 29 Message-ID: References: <86c4a53b-1ca1-48a8-b954-c01bd449278a@s35g2000prm.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 17 Sep 2011 01:03:03 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="f8igmItKsWs6nM5YanFxAA"; logging-data="18380"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+aZ47JD/3+7w/sUCRC7drN" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 In-Reply-To: Cancel-Lock: sha1:7LPLvnscJkzDUgHrmqV6CEYhN5k= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8098 On 9/16/2011 8:54 PM, Wanja Gayk wrote: > In article, esosman@ieee-dot-org.invalid > says... > >>>> Very nice! Would you care to try this approach on a shorter >>>> input array, like >>>> >>>> data = new int[] { Integer.MAX_VALUE }; >>>> >>>> This case should be quite simple, since the array is already sorted. >>>> Let us know how you make out, will you? >>> >>> I didn't say it works for any array out there, did I? >> >> Ah. Then I claim I can sort an array of integers in O(0) time. >> (And my claim is O(as worthwhile) as yours.) > > Those constraints would be pretty useless though. On the other hand: > Sorting numbers of a limited range is pretty common. > Either way I would argue that sorting an empty or one-element array is > no sorting at all. Fine. Then sort data = new int[] { Integer.MAX_VALUE, 1, 3, 1, 4, 1, 5, 9 }; -- Eric Sosman esosman@ieee-dot-org.invalid