Solved

Assuming a Method Int FindMax(int Array[ ],Int Last)that Returns the Subscript of the Subscript

Question 9

Multiple Choice

Assuming a method
Int findMax(int array[ ],int last) that returns the subscript of the largest value in the portion of an array whose elements are at 0 through last (inclusive) ,a method for sorting an array in ascending order can be written as follows:
Void sort(int array[ ]) {
For (int last = array.length-1;last >=1;last --) {
Int maxPos = findMax(array,last) ;
// Code is missing
}
}
If a method
Void swap(int array[ ],int pos1,int pos2) can be used to swap the contents of two array entries,then the logic for the missing code is


A) swap(array,maxPos,last) ;
B) swap(array,maxPos,last-1.;
C) swap(array,array[maxPos],array[last].;
D) sway(array,array[maxPos],array[last-1].;

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents