Sorting Visualization is a graphical application that visualizes various sorting algorithms using SDL (Simple DirectMedia Layer) and SDL_ttf (SDL TrueType Font). The application demonstrates how different sorting algorithms work by providing a visual representation of the sorting process. The latest update introduces multi-threading to separate the sorting and rendering processes, improving performance and responsiveness.
DemoVid2v.mp4
- Visualizes the following sorting algorithms:
- Bubble Sort
- Selection Sort
- Insertion Sort
- Binary Insertion Sort
- Shell Sort
- Heap Sort
- Quick Sort
- Merge Sort
- Counting Sort (Positive Integers Only)
- Radix Sort (Positive Integers Only)
- Bucket Sort (Positive Integers Only)
- Allows both positive and negative integers (flag to include negavtive integers)
- Adjustable number of elements to sort
- Customizable window size
- Real-time sorting process visualization
- Time measurement for sorting process
-
Update C++ Version to 20:
- Go to your project properties.
- Under
Configuration Properties
>General
, set theC++ Language Standard
toISO C++20 Standard (/std:c++20)
.
-
Add Include Directories:
- Go to
Configuration Properties
>VC++ Directories
>Include Directories
. - Add the following paths: (Might differ, select where you have copied the downloaded SDL files)
C:\libraries\SDL2\SDL2-2.30.3\include C:\libraries\SDL2\SDL2_image-2.8.2\include C:\libraries\SDL2\SDL2_ttf-2.22.0\include
- Go to
-
Add Library Directories:
- Go to
Configuration Properties
>VC++ Directories
>Library Directories
. - Add the following paths: (Might differ, select where you have copied the downloaded SDL files)
C:\libraries\SDL2\SDL2-2.30.3\lib\x64 C:\libraries\SDL2\SDL2_image-2.8.2\lib\x64 C:\libraries\SDL2\SDL2_ttf-2.22.0\lib\x64
- Go to
-
Add Linker Dependencies:
- Go to
Configuration Properties
>Linker
>Input
>Additional Dependencies
. - Add the following libraries:
SDL2.lib SDL2main.lib SDL2_ttf.lib SDL2_image.lib
- Go to
-
Update System Environment Path:
- If you encounter
SDL2_ttf.dll not found
error when running the project, add the SDL library directory to your system environment variablePATH
.C:\libraries\SDL2\SDL2-2.30.3\lib\x64 C:\libraries\SDL2\SDL2_image-2.8.2\lib\x64 C:\libraries\SDL2\SDL2_ttf-2.22.0\lib\x64
Refer to Setting up SDL2 in Windows (Visual Studio) for detailed steps.
- If you encounter
-
Clone the repository:
git clone /~https://github.com/Shreyas9699/Sorting-Visualization.git cd Sorting-Visualization
-
Build the project:
- Open the solution file in Visual Studio.
- Build the project by selecting
Build
>Build Solution
or pressingCtrl+Shift+B
.
-
Run the application:
- Run the project by selecting
Debug
>Start Debugging
or pressingF5
.
- Run the project by selecting
-
Select the number of elements to sort:
- Enter a value between 10 and 1440 in console.
-
Select the sorting algorithm:
- Choose an algorithm by entering the corresponding number:
1. Bubble Sort 2. Selection Sort 3. Insertion Sort 4. Binary Insertion Sort 5. Shell Sort 6. Heap Sort 7. Quick Sort 8. Merge Sort 9. Counting Sort 10. Radix Sort 11. Bucket Sort
- Choose an algorithm by entering the corresponding number:
-
Visualization:
- Watch the sorting process in real-time.
- The application will display the time taken for the sorting process upon completion.
-
Reset:
- After the sorting is done, you can close the SDL window by clicking on close button or ESC key.
- You can then choose to reset and try another configuration by entering 'Y' when prompted.
-
Engine.h & Engine.cpp:
- Contains the
Engine
class which manages the application state, rendering, and interaction with sorting algorithms.
- Contains the
-
main.cpp:
- Handles user input to configure and run the sorting visualization.
- Validates input and initializes the
Engine
object.
-
SortingAlgo.h:
- Contains implementations of various sorting algorithms.
Contributions are welcome! Please open an issue or submit a pull request for any bug fixes or enhancements.