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 order.
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.

Exercise23_16 20 19 18 17 15 14 13 12 11 10 6. 5 3 Step Reset (b)
Step by Step Solution
3.45 Rating (165 Votes )
There are 3 Steps involved in it
import javafxapplicationApplication import javafxgeometryPos import javafxsceneScene import javafxscenecontrolButton import javafxscenecontrolLabel import javafxscenelayoutBorderPane import javafxscen... View full answer
Get step-by-step solutions from verified subject matter experts
