This is a sorting visualizer program written in C using the SDL2 library. It allows you to see how different sorting algorithms work by visualizing the sorting process in real-time.
This project was inspired by sorting algorithms visualizer videos on youtube.
To install and run the program, you will need to have the SDL2 library installed on your system. You can download the library from the official SDL website here.
- Download the SDL2 development libraries from the official website: https://github.com/libsdl-org/SDL/releases/
- Extract the downloaded archive and navigate to the "lib" folder.
- Copy the contents of the "lib" folder to your project's lib directory.
- Copy the contents of the "include" folder to your project's include directory.
Installing through homebrew
brew install sdl2
platform | install command |
---|---|
Ubuntu/Debian | apt-get install libsdl2-dev |
CentOS/Fedora | dnf install SDL2-devel |
Arch Linux | pacman -S sdl2 |
Gentoo Linux | emerge -av media-libs/libsdl2 |
Once you have downloaded and installed the SDL2 library, you can clone this repository and run the program using the following commands:
git clone https://github.com/ShellTux/Sorting-Visualizer-in-C
cd Sorting-Visualizer-in-C
make
make
compiles and run the executable.
After compiling to just run the program, just:
./main.o
You can also run the program using a specific algorithm and visualizing method, for example:
./main.o "Quick Sort" "Colored Circle"
For other algorithms see Usage section
The following sorting algorithms are currently supported by the program:
- Bubble Sort
- Cocktail Sort
- Comb Sort
- Cycle Sort
- Gnome Sort
- Heap Sort
- Insertion Sort
- Merge Sort
- Odd-Even Sort
- Quick Sort
- Radix Sort
- Selection Sort
- Shell Sort
At the moment, there are 2 ways to methods to visualize sorting:
- Bars
- Colored Circle
If you would like to contribute to this project, please fork the repository and submit a pull request.