Multiple Choice
Consider the sort method shown below for selection sort:
public static void sort(int[] a) {
For (int i = 0; i < a.length - 1; i++)
{
int minPos = minimumPosition(i) ;
swap(minPos, i) ;
}
}
Suppose we modify the loop condition to read i < a.length. What would be the result?
A) An exception would occur.
B) The sort would work, but run one more iteration.
C) The sort would work but with one less iteration.
D) The sort would work exactly the same as before the code modification.
Correct Answer:

Verified
Correct Answer:
Verified
Q3: Suppose objects a and b are from
Q12: Suppose you wish to implement the Comparable
Q17: How many times can an array with
Q21: An algorithm that cuts the work in
Q26: In each iteration, selection sort places which
Q40: Which of the following arrays can be
Q63: Suppose an array has n elements. We
Q66: Suppose we are using binary search on
Q80: Consider the sort method for selection sort
Q97: Which sort algorithm starts with an initial