Quick { public int partition(List<T> A, int p, int r) { T x = A.get(r); int i = p - 1; for (int j = p; j <= (r - 1); j++) { if (A.get(j).compareTo(x) < 0) { i += 1; exchange(A, i, j); } } exchange(A, i+1, r); return (i+1); } Quick();   Quick(Random generator); int partition(List<T> A, int p, int r); int randomizedPartition(List<T> A, int p, int r); void randomizedQuicksort(List<T> A, int p, int r); void quicksort(List<T> A, int p, int r);  }
@Test public void testPartition() { List<Integer> input = Arrays.asList(5, 7, 9, 1, 3, 4); List<Integer> expectedOutput = Arrays.asList(1, 3, 4, 5, 7, 9); int newPivot = tester.partition(input, 0, input.size() - 1); assertEquals(2, newPivot); assertArrayEquals(expectedOutput.toArray(), input.toArray()); }