/** * Sorts the given arrays in descending order, using heap-sort. * @param A double[] the first array to be sorted. * @param B int[] the second array to be sorted, according to the * values of the first array. */ public static final void descendingHeapSort(double[] A, int[] B, short[] C) { HeapSort.ascendingHeapSort(A, B, C); reverse(A, B, C, A.length); } /**
/** * Sorts the given arrays in descending order, using heap-sort. * @param A double[] the first array to be sorted. * @param B int[] the second array to be sorted, according to the * values of the first array. */ public static final void descendingHeapSort(double[] A, int[] B, short[] C) { HeapSort.ascendingHeapSort(A, B, C); reverse(A, B, C, A.length); } /**
/** * Sorts the top <tt>topElements</tt> of the given array in * descending order, using heap sort for sorting the values * in ascending order and then reversing the order of a * specified number of elements. * @param A double[] the first array to be sorted. * @param B int[] the second array to be sorted, according to the * values of the first array. * @param topElements int the number of elements to be sorted. */ public static final void descendingHeapSort(final double[] A, final int[] B, final short[] C, final int topElements) { ascendingHeapSort(A, B, C, topElements); reverse(A, B, C, topElements); } /**
/** * Sorts the top <tt>topElements</tt> of the given array in * descending order, using heap sort for sorting the values * in ascending order and then reversing the order of a * specified number of elements. * @param A double[] the first array to be sorted. * @param B int[] the second array to be sorted, according to the * values of the first array. * @param topElements int the number of elements to be sorted. */ public static final void descendingHeapSort(final double[] A, final int[] B, final short[] C, final int topElements) { ascendingHeapSort(A, B, C, topElements); reverse(A, B, C, topElements); } /**
@Test public void testSortAllItems() { // Insert code to start the application here. double[] test = new double[] { 3, 5, 2, 1, 6, 7, 9, 8, 0, 4 }; int[] testIds = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; short[] testShorts = new short[test.length]; HeapSort.ascendingHeapSort(test, testIds, testShorts, test.length); assertTrue(isAscending(test)); HeapSort.descendingHeapSort(test, testIds, testShorts, test.length); assertTrue(isDescending(test)); } }