Please use this as a start public void sortOfSort(int[] array) // #13 {method he
ID: 3584470 • Letter: P
Question
Please use this as a start public void sortOfSort(int[] array) // #13 {method here}
Write method sortOf Sort that modifies the parameter array to place the largest integer at index n-1 and the smallest integer at array [0]. The others elements must still be in the array, but not in any particular order. You must modify the given array argument by changing array in method sortOfSort. Original Array Modified Array (all elements except the first and last may differ in order) {4, 3, 2, 0, 1, 2} {0, 3, 2, 1, 2, 4} {4, 3, 2, 1} {1, 3, 2, 4} {1, 3, 2, 4} {1, 3, 2, 4} The following assertions must pass:Explanation / Answer
//find smallest index for(int i=1;iarray[i]){ smallIdx=i;} } if(smallIdx!=0){ temp=array[0]; array[0]=array[smallIdx]; array[smallIdx]=temp; } //find largest index for(int j=1;jRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.