Question: Consider the sort method shown below for selection sort: public static void sort(int[] a) { for (int i = 0; i < a.length 1; i++)
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 call to the swap method call to read swap(i, minPos). What would be the result?
| The sort would produce incorrect results. |
| The sort would work, but sort backwards. |
| The sort would produce correct results. An exception would occur. |
|
If a call to the Arrays static method binarySearch returns a value of 7, what can be concluded? I the element is not in the array II the element is at index 7 III the element occurs 7 times in the array
|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
