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

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 algorithm)

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!