The largestPosition method below returns the index of the la…
The largestPosition method below returns the index of the largest element in the tail range of an array of integers. Select the expression that would be needed to complete the selectionSort method below, so that it sorts the elements in descending order. /** Finds the largest element in the tail range of an array. @param a the array to be searched @param from the first position in a to compare @return the position of the largest element in range a[from]..a[a.length – 1] */ private static int largestPosition(int[] a, int from) { int maxPos = from; for(int j = from + 1; j < a.length; j++) { if (a[j] > a[maxPos]) { maxPos = j; } } return maxPos; } public static void selectionSort(int[] a) { for____________________________________ { int maxPos = largestPosition(a, i); ArrayUtil.swap(a, maxPos, i); } }
Read Details