Bubble Sort Visualizer

This look lke a fun project.

To visualize well, you need to use a Clock Timer instead of a loop, to give a chance for the user to see what's happening.

For a sort, one comparison per Clock Timer cycle should be okay.

If you want to add sounds, the Player component has an Event block that can fire at end of sound. You can use that instead of the Clock Timer to advance the show, assuming you have short audio clips.

Expect to need a few global variables:

  • The list being sorted
  • The index into that list marking the boundary between unsorted and sorted portions
  • the current sweep location across the lower part of the list.

There is an upcoming graph component you can try if you are lazy like me.
It is at the bottom of the FAQ

1 Like