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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started