/** * Sorts the given arrays in ascending 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 ascendingHeapSort(double[] A, int[] B, short[] C) { int heapSize = buildMaxHeap(A, B, C); //temporary variables for swaps double tmpDouble; int tmpInt; short tmpShort; for (int i = A.length; i > 0; i--) { //swap elements in i-1 with 0 tmpDouble = A[i - 1]; A[i - 1] = A[0]; A[0] = tmpDouble; tmpInt = B[i - 1]; B[i - 1] = B[0]; B[0] = tmpInt; tmpShort = C[i - 1]; C[i - 1] = C[0]; C[0] = tmpShort; heapSize--; maxHeapify(A, B, C, 1, heapSize); } } /**
int heapSize = buildMaxHeap(A, B, C); int end = A.length - topElements;
/** * Sorts the given arrays in ascending 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 ascendingHeapSort(double[] A, int[] B, short[] C) { int heapSize = buildMaxHeap(A, B, C); //temporary variables for swaps double tmpDouble; int tmpInt; short tmpShort; for (int i = A.length; i > 0; i--) { //swap elements in i-1 with 0 tmpDouble = A[i - 1]; A[i - 1] = A[0]; A[0] = tmpDouble; tmpInt = B[i - 1]; B[i - 1] = B[0]; B[0] = tmpInt; tmpShort = C[i - 1]; C[i - 1] = C[0]; C[0] = tmpShort; heapSize--; maxHeapify(A, B, C, 1, heapSize); } } /**
int heapSize = buildMaxHeap(A, B, C); int end = A.length - topElements;