Question: Write a program in Java that animates the bubble sort algorithm. Create an array that consists of 20 distinct numbers from 1 to 20 in

Write a program in Java 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 com- parison 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 cre- ates a new random array for a new start.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
