Question: Consider the following implementation of the selection sort algorithm for an Array of doubles. public static int selectSort ( double [ ] arr ) {

Consider the following implementation of the selection sort algorithm for an Array of doubles.
public static int selectSort(double[] arr){
int count =0;
for (int i =0; i < arr.length -1; i++){
int place = i;
for (int j = i +1; j < arr.length; j++){
count++;
if (arr[j]< arr[place]){
place = j;
}
}
double temp = arr[i];
arr[i]= arr[place];
arr[place]= temp;
}
return count;
}
The method returns an int which represents a statement execution count. What will this value be when the method returns if the parameter list is the array {3.3,4.7,1.2,4.1}:

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!