Unit 4 · Data Collections
Sorting and Efficiency
Sorting and Efficiency MCQ Practice
Question 1 of 15
Answered 0 of 15
Choose one answer.
The array below is sorted into increasing order by selection sort. What does it hold after the first pass?
public static void selectionPass(int[] values, int start)
{
int least = start;
for (int index = start + 1; index < values.length; index++)
{
if (values[index] < values[least])
{
least = index;
}
}
int saved = values[start];
values[start] = values[least];
values[least] = saved;
}
int[] a = {5, 2, 8, 1};
selectionPass(a, 0);