Question: Write a class named BubbleSort with the following methods and functionality: Write a bubbleSort method that implements a sort method that uses the bubble-sort algorithm.
Write a class named BubbleSort with the following methods and functionality: Write a bubbleSort method that implements a sort method that uses the bubble-sort algorithm. Your source in this method must use at least one (1) while loop. public static int[] bubbleSort(int[] array) Write a main method that: Prompts the user to enter 10 integers Calls the bubbleSort method, passing it the 10 integer array. Retrieves the sorted array from bubbleSort and displays the array to the screen.
Hint: The bubble-sort algorithm makes several passes through the array. On each pass, successive neighboring pairs are compared. If a pair is in decreasing order, its values are swapped; otherwise, the values remain unchanged. The technique is called a bubble sort or sinking sort because the smaller values gradually bubble their way to the top and the larger values sink to the bottom.
Heres a sample run: Enter 10 integer values: 54 92 4 59 72 68 40 64 63 7 Bubble-sorted array: 4 7 40 54 59 63 64 68 72 92
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
