Question: The following incomplete method is intended to sort its array paramter arr in increasing order. //postcondition: arr is sorted in increasing order public static void

The following incomplete method is intended to sort its array paramter arr in increasing order.
//postcondition: arr is sorted in increasing order public static void sortArray(int[] arr) { int j, k;
for (j = arr.length - 1; j > 0; j--) { int pos = j;
for ( /* missing code */) { if (arr[k] > arr[pos]) { pos = k; } } swap (arr, j, pos); } }
Assume that swap (arr, j, pos) exchanges the values of arr[j] and arr[pos]. Which of the following could be used to replace /* missing code */ so that executing the code segment sorts the values in array arr?
Question 17 options:
| |||
| |||
| |||
| |||
|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
