A program for visualizing sorting algorithms.
This is my freshman year summer project! Trying to get a better understanding of sorting algorithms before my Data Structures and Algorithms class this fall while applying new things i've learned such as Swing, git, and multi-threading.
You must have a JDK installed on your system Download JDK
- Clone he project onto your system 'https://github.com/dlarocque/AlgorithmVisualizer'.
- Download the .zip file from https://github.com/dlarocque/AlgorithmVisualizer and extract its contents.
OR
- Download the Executable JAR file 'AlgVisualizer.jar'.
First, make sure your PATH and JAVA_HOME Environment variables are set correctly.
- You can simply go through your file system and find the AlgVisualizer.jar you downloaded. Simply open it, and the program will start
OR
- Through the terminal, you can go to
C:/.../AlgorithmVisualizerand enter
AlgorithmVisualizer.jar
- Go to
C:/.../AlgorithmVisualizer/srcand enter
javac AlgVisualizer.java
-
This will compile the program into a binary file, where you can now find by going to
C:/.../AlgorithmVisualizer/bin -
If there are no issues, you can now go to
C:/.../AlgorithmVisualizer/binand run the program with
java com.example.algorithmvisualizer.AlgVisualizer
On startup, the application will open up a frame containing buttons and an unsorted array in bar form. There is a Reset button, a button for each sorting algorithm, a drop down size changer, an FPS slider, and a label showing the sorting performance.
The Reset Button will re-shuffle the array and stop any sorting that is being done, while keeping the size set to the array.
The Sort Buttons will be available when sorting isn't being done. Clicking any of them will start sorting the displayed array with the selected sorting algorithm.
The Size Changer is initially set at N = 10, clicking it will open a drop down menu listing the available array sizes, clicking any of them will stop sorting and display a new array of the chosen size.
The FPS Slider is initialially set at 10 fps, it ranges from 1 fps all the way to 100 fps. This slider can be used to speed up the sorting / visualization process on bigger arrays or slow it down to get a better understanding of the sorting process on smaller arrays. It can be used before, during, and after sorting.
The Performance Label between the array and the buttons displays all of the stats that can help the user understand how different sorting algorithms perform compared to each other. (It's interesting to see how bubble sort is better performing than merge and quick sort on small arrays)
The time to visualize the sorting of one of the algorithms is not a good representation of its real sorting time. This is because the arr is updated every time there is an index swap, this makes it so that sorting algorithms with fewer swaps are visualized much faster. This is the reasoning behind including a 'Sorting Time' stat along with 'Visualzation Time' in the Performance label.
The main window is not resizable due to the way that the bar graph is drawn. For example, if the width of the content pane is changed from 800 to 822, with an array N = 10, the drawing will not fill the entire window. Initially, the value of an index in the array was represented by an 80 inch wide bar, now it would be 82 and leaving a 2 pixel wide empty space in the frame. This is Issue #15
- Daniel La Rocque dlarocque
This project is licensed under the MIT License. See LICENSE.txt for more details
If there is an issue with the application, please take a look at issues. If your issue is not already listed, please create a new issue that describes your problem!
Inspiration for the project https://www.youtube.com/watch?v=kPRA0W1kECg