@Test public void testBucketSort() { int[] arr = new int[] { 17, 3, 99, 51 }; int[] expected = new int[] { 3, 17, 51, 99 }; int[] actual = Sorter.bucketSort(arr); Assert.assertArrayEquals(expected, actual); }
public static int[] bucketSort(int[] arr) { int[][] buckets = scatter(arr); ArrayDeque<int[]> stack = new ArrayDeque<int[]>(); for (int[] bucket : buckets) { if (bucket != null) { stack.add(mergeSort(bucket)); } } return gather(stack); }
Sorter { public static int[] bucketSort(int[] arr) { int[][] buckets = scatter(arr); ArrayDeque<int[]> stack = new ArrayDeque<int[]>(); for (int[] bucket : buckets) { if (bucket != null) { stack.add(mergeSort(bucket)); } } return gather(stack); } }
Sorter { public static int[] bucketSort(int[] arr) { int[][] buckets = scatter(arr); ArrayDeque<int[]> stack = new ArrayDeque<int[]>(); for (int[] bucket : buckets) { if (bucket != null) { stack.add(mergeSort(bucket)); } } return gather(stack); }  }
Sorter { public static int[] bucketSort(int[] arr) { int[][] buckets = scatter(arr); ArrayDeque<int[]> stack = new ArrayDeque<int[]>(); for (int[] bucket : buckets) { if (bucket != null) { stack.add(mergeSort(bucket)); } } return gather(stack); }  static int[] mergeSort(int[] arr); static int[] quickSort(int[] arr); static int[] bucketSort(int[] arr); static Integer[] countingSort(final int[] arr); }
Sorter { public static int[] bucketSort(int[] arr) { int[][] buckets = scatter(arr); ArrayDeque<int[]> stack = new ArrayDeque<int[]>(); for (int[] bucket : buckets) { if (bucket != null) { stack.add(mergeSort(bucket)); } } return gather(stack); }  static int[] mergeSort(int[] arr); static int[] quickSort(int[] arr); static int[] bucketSort(int[] arr); static Integer[] countingSort(final int[] arr);  }