Question: Write a program that animates the bubble sort algorithm. Create an array that consists of 20 distinct numbers from 1 to 20 in a random
Write a program that animates the bubble sort algorithm. Create an array that consists of 20 distinct numbers from 1 to 20 in a random order. The array elements are displayed in a histogram, as shown in Figure 23.20b. Clicking the Step button causes the program to perform one comparison in the algorithm and repaints the histogram for the new array. Color the bar that represents the number being considered in the swap. When the algorithm is finished, display a message to inform the user. Clicking the Reset button creates a new random array for a new start.
20 19 18 17 16 15 14 13 12 11 10 6. 4 3 Step Reset (b) 5. 69
Step by Step Solution
3.40 Rating (156 Votes )
There are 3 Steps involved in it
Program Plan Create a BubbleSortAnimation class to animate the bubble sort Create the Scene and Bord... View full answer
Get step-by-step solutions from verified subject matter experts
