Question: JAVA: Integer Arrays sorting SAMPLE OUTPUTS: *Array* before selection sort: [11, 2, 34, 14, 95, 26, 7, 18, 9, 16] --Found next smallest value: 2
JAVA: Integer Arrays sorting

![34, 14, 95, 26, 7, 18, 9, 16] --Found next smallest value:](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f4e219ef26e_69766f4e21949414.jpg)

SAMPLE OUTPUTS:
*Array* before selection sort: [11, 2, 34, 14, 95, 26, 7, 18, 9, 16] --Found next smallest value: 2 at index 1. ---Swap elements at index 0 and 1 -Array after loop where i= 0: [2, 11, 34, 14, 95, 26, 7, 18, 9, 16] --Found next smallest value: 7 at index 6. ---Swap elements at index 1 and 6 -Array after loop where i= 1: [2, 7, 34, 14, 95, 26, 11, 18, 9, 16] --Found next smallest value: 9 at index 8. ---Swap elements at index 2 and 8 -Array after loop where i= 2: [2, 7, 9, 14, 95, 26, 11, 18, 34, 16] --Found next smallest value: 11 at index 6. ---Swap elements at index 3 and 6 -Array after loop where i= 3: [2, 7, 9, 11, 95, 26, 14, 18, 34, 16] --Found next smallest value: 14 at index 6. ---Swap elements at index 4 and 6 -Array after loop where i= 4: [2, 7, 9, 11, 14, 26, 95, 18, 34, 16] --Found next smallest value: 16 at index 9. ---Swap elements at index 5 and 9 -Array after loop where i= 5: [2, 7, 9, 11, 14, 16, 95, 18, 34, 26] --Found next smallest value: 18 at index 7. ---Swap elements at index 6 and 7 -Array after loop where i= 6: [2, 7, 9, 11, 14, 16, 18, 95, 34, 26] --Found next smallest value: 26 at index 9. ---Swap elements at index 7 and 9 -Array after loop where i= 7: [2, 7, 9, 11, 14, 16, 18, 26, 34, 95] --Found next smallest value: 34 at index 8. ---Swap elements at index 8 and 8 -Array after loop where i= 8: [2, 7, 9, 11, 14, 16, 18, 26, 34, 95] *Array* after selection sort: [2, 7, 9, 11, 14, 16, 18, 26, 34, 95] Press
*Array* before insertion sort: [11, 2, 34, 14, 95, 26, 7, 18, 9, 16] --Insert 2 into sorted numbers before 2 ---Swap elements at index 1 and 0 -Array after loop where i= 1: [2, 11, 34, 14, 95, 26, 7, 18, 9, 16] --Insert 34 into sorted numbers before 34 -Array after loop where i= 2: [2, 11, 34, 14, 95, 26, 7, 18, 9, 16] --Insert 14 into sorted numbers before 14 ---Swap elements at index 3 and 2 -Array after loop where i= 3: [2, 11, 14, 34, 95, 26, 7, 18, 9, 16] --Insert 95 into sorted numbers before 95 -Array after loop where i= 4: [2, 11, 14, 34, 95, 26, 7, 18, 9, 16] --Insert 26 into sorted numbers before 26 ---Swap elements at index 5 and 4 ---Swap elements at index 4 and 3 -Array after loop where i= 5: [2, 11, 14, 26, 34, 95, 7, 18, 9, 16] --Insert 7 into sorted numbers before 7 ---Swap elements at index 6 and 5 ---Swap elements at index 5 and 4 ---Swap elements at index 4 and 3 ---Swap elements at index 3 and 2 ---Swap elements at index 2 and 1 -Array after loop where i= 6: [2, 7, 11, 14, 26, 34, 95, 18, 9, 16] --Insert 18 into sorted numbers before 18 ---Swap elements at index 7 and 6 ---Swap elements at index 6 and 5 ---Swap elements at index 5 and 4 -Array after loop where i= 7: [2, 7, 11, 14, 18, 26, 34, 95, 9, 16] --Insert 9 into sorted numbers before 9 ---Swap elements at index 8 and 7 ---Swap elements at index 7 and 6 ---Swap elements at index 6 and 5 ---Swap elements at index 5 and 4 ---Swap elements at index 4 and 3 ---Swap elements at index 3 and 2 -Array after loop where i= 8: [2, 7, 9, 11, 14, 18, 26, 34, 95, 16] --Insert 16 into sorted numbers before 16 ---Swap elements at index 9 and 8 ---Swap elements at index 8 and 7 ---Swap elements at index 7 and 6 ---Swap elements at index 6 and 5 -Array after loop where i= 9: [2, 7, 9, 11, 14, 16, 18, 26, 34, 95]
*Array* after insertion sort: [2, 7, 9, 11, 14, 16, 18, 26, 34, 95] Press
*Array* before bubble sort: [11, 2, 34, 14, 95, 26, 7, 18, 9, 16] -Starting at index 1, bubbling up highest numbers until index 9 ---Swap elements at index 0 and 1 ---Swap elements at index 2 and 3 ---Swap elements at index 4 and 5 ---Swap elements at index 5 and 6 ---Swap elements at index 6 and 7 ---Swap elements at index 7 and 8 ---Swap elements at index 8 and 9 --Array after loop with i= 1: [2, 11, 14, 34, 26, 7, 18, 9, 16, 95]. -Starting at index 2, bubbling up highest numbers until index 9 ---Swap elements at index 3 and 4 ---Swap elements at index 4 and 5 ---Swap elements at index 5 and 6 ---Swap elements at index 6 and 7 ---Swap elements at index 7 and 8 --Array after loop with i= 2: [2, 11, 14, 26, 7, 18, 9, 16, 34, 95]. -Starting at index 3, bubbling up highest numbers until index 9 ---Swap elements at index 3 and 4 ---Swap elements at index 4 and 5 ---Swap elements at index 5 and 6 ---Swap elements at index 6 and 7 --Array after loop with i= 3: [2, 11, 14, 7, 18, 9, 16, 26, 34, 95]. -Starting at index 4, bubbling up highest numbers until index 9 ---Swap elements at index 2 and 3 ---Swap elements at index 4 and 5 ---Swap elements at index 5 and 6 --Array after loop with i= 4: [2, 11, 7, 14, 9, 16, 18, 26, 34, 95]. -Starting at index 5, bubbling up highest numbers until index 9 ---Swap elements at index 1 and 2 ---Swap elements at index 3 and 4 --Array after loop with i= 5: [2, 7, 11, 9, 14, 16, 18, 26, 34, 95]. -Starting at index 6, bubbling up highest numbers until index 9 ---Swap elements at index 2 and 3 --Array after loop with i= 6: [2, 7, 9, 11, 14, 16, 18, 26, 34, 95]. -Starting at index 7, bubbling up highest numbers until index 9 --Array after loop with i= 7: [2, 7, 9, 11, 14, 16, 18, 26, 34, 95]. -Starting at index 8, bubbling up highest numbers until index 9 --Array after loop with i= 8: [2, 7, 9, 11, 14, 16, 18, 26, 34, 95]. -Starting at index 9, bubbling up highest numbers until index 9 --Array after loop with i= 9: [2, 7, 9, 11, 14, 16, 18, 26, 34, 95].
*Array* after bubble sort: [2, 7, 9, 11, 14, 16, 18, 26, 34, 95] Press
*Array* before improved bubble sort: [11, 2, 34, 14, 95, 26, 7, 18, 9, 16] -Starting at index 1, bubbling up highest numbers until index 9 ---Swap elements at index 0 and 1 ---Swap elements at index 2 and 3 ---Swap elements at index 4 and 5 ---Swap elements at index 5 and 6 ---Swap elements at index 6 and 7 ---Swap elements at index 7 and 8 ---Swap elements at index 8 and 9 --Array after loop with k= 1: [2, 11, 14, 34, 26, 7, 18, 9, 16, 95]. -Starting at index 2, bubbling up highest numbers until index 9 ---Swap elements at index 3 and 4 ---Swap elements at index 4 and 5 ---Swap elements at index 5 and 6 ---Swap elements at index 6 and 7 ---Swap elements at index 7 and 8 --Array after loop with k= 2: [2, 11, 14, 26, 7, 18, 9, 16, 34, 95]. -Starting at index 3, bubbling up highest numbers until index 9 ---Swap elements at index 3 and 4 ---Swap elements at index 4 and 5 ---Swap elements at index 5 and 6 ---Swap elements at index 6 and 7 --Array after loop with k= 3: [2, 11, 14, 7, 18, 9, 16, 26, 34, 95]. -Starting at index 4, bubbling up highest numbers until index 9 ---Swap elements at index 2 and 3 ---Swap elements at index 4 and 5 ---Swap elements at index 5 and 6 --Array after loop with k= 4: [2, 11, 7, 14, 9, 16, 18, 26, 34, 95]. -Starting at index 5, bubbling up highest numbers until index 9 ---Swap elements at index 1 and 2 ---Swap elements at index 3 and 4 --Array after loop with k= 5: [2, 7, 11, 9, 14, 16, 18, 26, 34, 95]. -Starting at index 6, bubbling up highest numbers until index 9 ---Swap elements at index 2 and 3 --Array after loop with k= 6: [2, 7, 9, 11, 14, 16, 18, 26, 34, 95]. -Starting at index 7, bubbling up highest numbers until index 9 --Array after loop with k= 7: [2, 7, 9, 11, 14, 16, 18, 26, 34, 95]. Improved bubble sort executed 2 less loops.
*Array* after improved bubble sort: [2, 7, 9, 11, 14, 16, 18, 26, 34, 95] Press
(pg1) Description This program will use an array of integers and provide multiple ways to sort the contents. To better understand the mechanics, your sort methods wi include some additional print statements to show the "decisions" being made in each algorithm. See the sample output. Requirements . Method main) o Use the following main) method in your program to execute your methods See the output at the end for an example of what your methods will display: public static void main(String] args) Scanner input new Scanner(System.in); // test selection sort int] numbersl(11,2,34, 14,95,26,7,18,9,16); System.out.printf(" *Array" before selection sort: %s ",Arrays.tostring(numbers1)); selectionSort (numbers1); System.out.printf(" *Array" after selection sort: %s ", Arrays . toString(numbers1)); System.out.println("Press
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
