Question: Find two different approaches to alter the following selectionsort method so that it sorts in descending order instead of ascending order. public static void selectionSort

Find two different approaches to alter the following selectionsort method so that it sorts in descending order instead of ascending order.
public static void selectionSort(int[] elem){
for (int j=0;j elem.length -1;j++){
int minIdx =j;
for(int k=j+1;k elem.length; k++){
if(elem[k] elem[minIdx])
minIdx=k;
}
if(elem[minIdx] elem[j]){
int temp = elem[j];
elem [j]= elem[minIdx];
elem[minIdx]= temp;
}
}
}
 Find two different approaches to alter the following selectionsort method so

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 Databases Questions!