smile.sort
Class ShellSort
- java.lang.Object
-
- smile.sort.ShellSort
-
public class ShellSort extends java.lang.ObjectShell sort is a sorting algorithm that is a generalization of insertion sort, with two observations:- insertion sort is efficient if the input is "almost sorted", and
- insertion sort is typically inefficient because it moves values just one position at a time.
The original implementation performs O(n2) comparisons and exchanges in the worst case. A minor change given in V. Pratt's book improved the bound to O(n log2 n). This is worse than the optimal comparison sorts, which are O(n log n).
For n < 50, roughly, Shell sort is competitive with the more complicated Quicksort on many machines. For n > 50, Quicksort is generally faster.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static voidsort(double[] a)Sorts the specified array into ascending numerical order.static voidsort(float[] a)Sorts the specified array into ascending numerical order.static voidsort(int[] a)Sorts the specified array into ascending numerical order.static <T extends java.lang.Comparable<? super T>>
voidsort(T[] a)Sorts the specified array into ascending order.
-
-
-
Method Detail
-
sort
public static void sort(int[] a)
Sorts the specified array into ascending numerical order.
-
sort
public static void sort(float[] a)
Sorts the specified array into ascending numerical order.
-
sort
public static void sort(double[] a)
Sorts the specified array into ascending numerical order.
-
sort
public static <T extends java.lang.Comparable<? super T>> void sort(T[] a)
Sorts the specified array into ascending order.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG