This project is a C++ application that brings sorting algorithms to life using the SDL2 library. Built for our CSE-150 course, it transforms abstract code into colorful, dynamic visuals, making it easier to see and understand how different sorting algorithms work step-by-step. Whether you’re learning the basics or just curious about algorithm behavior, this tool turns theory into an interactive experience.
- Visualizes sorting algorithms step-by-step
- Interactive and educational
- Built with SDL2 for cross-platform graphics
- Windows OS (other platforms may require adjustments)
- g++ (MinGW recommended)
- SDL2 development libraries
- The project includes SDL2 headers and libraries in
src/includeandsrc/lib.
- The project includes SDL2 headers and libraries in
- Make (optional, for using the provided Makefile)
main.cpp # Main application source code
Makefile # Build script for compiling the project
SDL2.dll # SDL2 runtime DLL (required for execution)
src/
include/SDL2/ # SDL2 header files
lib/ # SDL2 library files
-
Open a terminal in the project directory.
-
Run the following command:
mingw32-make
This will compile
main.cppand link against the SDL2 libraries, producing an executable namedmain.exe.The Makefile uses:
g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2
-I src/includespecifies the location of SDL2 header files.-L src/libspecifies the location of SDL2 library files.-lmingw32 -lSDL2main -lSDL2links the required libraries.
-
Ensure
SDL2.dllis present in the project directory.- This DLL is required for the application to run.
- After building, run the executable:
Or double-click
./main.exe
main.exein the file explorer. - The application window will open, displaying the sorting visualization.
When you start the program, you will see a welcome message:
******************************WELCOME TO SORTING ALGORITHM VISUALIZER******************************
Press Enter to continue or -1 to exit the program:
- Press Enter to proceed to the sorting visualization.
- Enter -1 and press Enter to exit the program.
Once inside the visualizer:
- Follow any on-screen instructions to select or observe sorting algorithms.

- Pressing Enter will open the visualizer window

- Choose any instructions per the User Guide to start that particular sorting algorithm. The Green bar and Lavendar bar indicates the number that is being compared in that particular render.

- After sorting process completes, all the borders turn Dark Green

- The terminal outputs the unsorted array, the algorithm used, total time taken by the algorithm(with a delay of 150ms between each render), total comparisons, and the sorted array.

- Press Exit to exit the visualizer or you can carry on visualizing different algorithms following the User Guide
- The application uses SDL2 to create a graphical window.
- Sorting algorithms are implemented in C++ and visualized by updating the display as the algorithm progresses.
- Each step of the sorting process is rendered, allowing users to observe how elements are moved and sorted.
- The visualization helps users understand the inner workings and efficiency of different sorting algorithms.
- If you encounter errors related to missing SDL2 libraries, ensure that the
src/includeandsrc/libdirectories contain the necessary files. - Make sure
SDL2.dllis in the same directory asmain.exe.
This project is licensed under the MIT License. See the LICENSE file for details.
Note: The project uses SDL2, which is licensed separately. Please refer to the SDL2 license for details regarding the use of SDL2 libraries.
- SDL2: https://www.libsdl.org/
- Developed by Muntasir Mamun, Naila Nausheen Rahman and Yarus Hossain Rafi