Algorithm visualizer

The story began when I helped my boss to teach two lectures about really basic sorting algorithms. My plan was to show them how each algorithm would work, and then ask them to actually write pseudocode for them. So it would be very useful if I can show them the exact steps taken by the algorithms. I have seen a few sorting applets, and I want to take advantage of one of them. After some trial, I settled on one which shows the internal state of the algorithm (things like "the current value of i" and "will compare data[5] and data[6]") rather than just the current array.

The fun started when I found that the algorithm my boss used was slightly different from the algorithm used by the applet. I knew I had to live with it. So I wanted to modify the applet. Wow... it turned out that to do the visualization (i.e., to step through the algorithm), the author decided to turn the sorting algorithms into state machines. To modify the program I have to turn my sorting algorithm into a state machine. Not exactly a nice program: how I know whether the fabricated state machine really does exactly the same as the original program? What if I want to make a little further change?

I did it anyway, but I found it irresistible to write my own implementation, taking advantage of things like OO patterns and multi-threading to make the program easier to verify and maintain. All the algorithms that I actually implemented so far are sorting algorithms: bubble sort, insertion sort, selection sort, merge sort, quick sort and heap sort. However, I see no inherit barrier to use it for other non-sorting algorithms as well. In other words, I make it so that it can be a platform for visualizing many algorithms. So the name.

Download

Compiled JAR file, Source code

Instructions

To run it, do one of...

It should be intuitive enough for you to run various algorithms with various inputs, either stepping through it or run it multiple times to see its performance.

If you want to implement your own algorithms, note that the entry point is at algorithmic.visualizer.VisualizerUI, where the specifications of algorithms are located. You will be implementing new classes, producing a spec file, and adding an entry at the class above to make it available for running.

Screen shots

Visualizing a run of bubble sort
Configuring merge sort instance for visualization
Report after a timed run of quick sort