Question: refer to the following information public static void sort ( int [ ] data ) { for ( int j =

  refer to the following information
 
public static void sort(int[] data) 
{
 
 for (int j =0; j < data.length -1; j++) 
 
{
 
 int m = j; 
 
 for (int k = j +1; k < data.length; k++) 
 
 { if (data[k]< data[m])/* Compare values */ 
 
{
 
 = k; 
 
}
 
}
 
 int temp = data[m]/* Assign to temp */ 
 
 data[m]= data[j]; 
 
 data[j]= temp; 
 
 /* End of outer loop */ 
 
}
 
}
 
 Assume that sort is called with the array {1,2,3,4,5,6}. How many times will the 
 
 expression indicated by /* Compare values */ and the statement indicated by /* Assign to 
 
 temp */ execute? 
 
Compare values Assign to temp
 
 (A)150 
 
 (B)155 
 
 (C)156 
 
 (D)215 
 
 (E)216 
 

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!