Question: Reverse the following selection sort to sort the items from right to left by computing the max instead of min in java. (just write the
public class Selection{
public static void sort(Comparable[] a) {
// Sort a[] into increasing order.
int N = a.length;
// array length
for (int i = 0; i
// Exchange a[i] with smallest entry in a[i+1...N).
int min = i;
// index of minimal entr.
for (int j = i+1; j
if (less(a[j], a[min])) min = j;
exch(a, i, min);
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
