1. Consider the following code: public static void srt ( int[] a, int b) int i, m, t; if ( a.length - b al ml) mi; } t = a[b]; al bi = a[ ml; al m) t; srt ( a, b 1); Value: 1 point What is the output when the following code is executed? int[] a = 1 4, 2, 3, 1, 5 }; int i; srt ( a, 0); for (i = 0; i
0; i- ) { int p = 0; for (int k = 0;k ) P = k; ) if ( i != p) swap ( array, i, p ); } 3 2. Value: 1 point. Which of the following is a suitable replacement for A. array[ k] > array[p] B. array[ k] >p C. array[ k] >= p D. K > p E. K >= P 3. Value: 1 point. Which of the following is a suitable definition for swap? I. public static void swap( int[] a, int m, int n) al m ] = a[n]; al ] = a[ m); { 1 II. public static void swap( int[] a, int , int n) { al m) - an); al n) += al m); al m ] = a[n] - al ml; III. public static void swap( int[] a, int m, int n) { int x = al m); al m ] = a[n]; al n] = x; 3 A. I only B. II only C. III only D. II and III only E. I, II, and III 4. The following code is designed to implement an insertion sort: 1/ precondition: array has data type int[] int i, next, at, k; for (i = 0; i 0 && at == 0 ) { if ( next > array( k-1]) { at k; } else { ) k--; } array( at ) next; } Value: 1 point. Which of the following is a suitable replacement for ? A. array[ k] = next; B. array[ k] = array[ i -1]; C. array[ k] = array[ i +1]; D. array[ k] = array[ k 1]; E. array ] array[ k + 1]; 5. Value: 1 point. This array of ten integers 3 81 97 6 0 2 4 5 is to be sorted using a selection sort that, in each iteration, searches for the largest integer among those that have yet to be sorted, so that an array of integers in ascending order results. What is the arrangement of these integers after the first iteration? A. 0 1 2 3 4 5 6 7 8 9 B. 0 8 1 9 7 6 3 2 4 5 C. 3 8 1 5 7 6 0 2 4 9 D. 381 76 2 4 5 9 E. 5 8 1 9 7 6 0 2 4 5