Fill in the code to complete the following method for sorting a list.

public static void sort(double[] list) {
________;
}

public static void sort(double[] list, int high) {
if (high > 1) {
// Find the largest number and its index
int indexOfMax = 0;
double max = list[0];
for (int i = 1; i <= high; i++) {
if (list[i]> max) {
max = list[i];indexOfMax = i;
}
}

// Swap the largest with the last number in the list
list[indexOfMax] = list[high];
list[high] = max;

// Sort the remaining list
sort(list, high - 1);
}
}

Respuesta :

Answer:

sort(list,list.length-1);

Explanation:

The appropriate code to implement to sort the list in the given program is sort(list, list.length-1)

This is used for sorting every member of the list since indexing at Java starts from 0, hence the last member of the list will have the (n-1) position in sorting where n signifies the number pf members or list length in this instance.

ACCESS MORE
ACCESS MORE
ACCESS MORE
ACCESS MORE