Re: java.util.DualPivotQuickSort does not guarantee NlogN time

2015-01-27 Thread Jeff Hain
An ugly but non-intrusive workaround, that would not add much overhead for usual cases,taking advantage of quadraticness blowing up in stack overflow before long: public class ParanoidSort {    public static void sort(Object[] a) {     try {     Arrays.sort(a);     } catch (Stac

Re: java.util.DualPivotQuickSort does not guarantee NlogN time

2015-01-27 Thread Joseph D. Darcy
On 1/27/2015 12:15 PM, Doug Lea wrote: On 01/27/2015 08:44 AM, Buis, Paul wrote: The slowdown would be passing a single extra integer parameter, decrementing it and comparing it to zero at the beginning of the function. Right. The question is whether even a small slowdown is warranted. Does

Re: java.util.DualPivotQuickSort does not guarantee NlogN time

2015-01-27 Thread Doug Lea
On 01/27/2015 08:44 AM, Buis, Paul wrote: The slowdown would be passing a single extra integer parameter, decrementing it and comparing it to zero at the beginning of the function. Right. The question is whether even a small slowdown is warranted. Does quadratic behavior arise more that once

Re: java.util.DualPivotQuickSort does not guarantee NlogN time

2015-01-27 Thread Buis, Paul
The slowdown would be passing a single extra integer parameter, decrementing it and comparing it to zero at the beginning of the function. With an initial value of 4*logN, heapsort would hardly ever be called in practice, only after a long series of unfortundate pivot choices that indicate the

Re: java.util.DualPivotQuickSort does not guarantee NlogN time

2015-01-27 Thread Doug Lea
On 01/26/2015 03:05 PM, Buis, Paul wrote: DualPivotQuickSort is used by Arrays.sort() and provides NlogN average performance, but does not guarantee NlogN worst case performance. It would be relatively easy to incorporate the basic idea of IntroSort (see http://en.wikipedia.org/wiki/Introsort) to

Re: java.util.DualPivotQuickSort does not guarantee NlogN time

2015-01-26 Thread Jeff Hain
Hi. >It would be relatively easy to incorporate the basic idea of IntroSort (see >http://en.wikipedia.org/wiki/Introsort) For the record, I tried (not too hard :) to get it piggy-backed into DualPivotQuickSort-related modifications, but without success : http://mail.openjdk.java.net/pipermail/c

java.util.DualPivotQuickSort does not guarantee NlogN time

2015-01-26 Thread Buis, Paul
DualPivotQuickSort is used by Arrays.sort() and provides NlogN average performance, but does not guarantee NlogN worst case performance. It would be relatively easy to incorporate the basic idea of IntroSort (see http://en.wikipedia.org/wiki/Introsort) to provide such a guarantee. To make this