Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Consider the following code: public static void srt ( int[] a, int b) int i, m, t; if ( a.length - b al ml)

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

What is informatics? Give three examples.

Answered: 1 week ago