Skip to main content

Quick Start

Follow these steps to build and run the Sorting Algorithms Visualiser on your system. You’ll be visualizing sorting algorithms in just a few minutes!

Prerequisites

Before you begin, make sure you have the following installed:
  • Windows Operating System (the application is built for Windows)
  • C++ Compiler: Visual Studio 2019/2022 or compatible C++ compiler with C++20 support
  • vcpkg: Microsoft’s C++ package manager for dependency management
  • Git: For cloning the repository
This project uses SFML 2.6.2 for graphics rendering. The dependency is managed automatically through vcpkg.

Installation Steps

1

Clone the Repository

Open your terminal and clone the Sorting Algorithms Visualiser repository:
git clone https://github.com/DevBoiAgru/SortingAlgorithmsVisualiser.git
cd SortingAlgorithmsVisualiser
This creates a local copy of the project on your machine.
2

Install Dependencies with vcpkg

The project requires SFML (Simple and Fast Multimedia Library). Install it using vcpkg:
vcpkg install sfml:x64-windows
This command installs SFML version 2.6.2 as specified in vcpkg.json.
If you haven’t set up vcpkg integration with Visual Studio, run:
vcpkg integrate install
This allows Visual Studio to automatically find vcpkg packages.
3

Build the Project

Using Visual Studio

  1. Open the solution file (SortingAlgos.sln) in Visual Studio
  2. Set the build configuration to Release or Debug (x64)
  3. Build the solution: Build > Build Solution (or press Ctrl+Shift+B)
  4. The executable will be generated in the output directory

Using Command Line (MSVC)

If you prefer command-line compilation:
cl /EHsc /std:c++20 /I"path\to\vcpkg\installed\x64-windows\include" ^
   SortingAlgos.cpp /link /LIBPATH:"path\to\vcpkg\installed\x64-windows\lib" ^
   sfml-graphics.lib sfml-window.lib sfml-system.lib /OUT:SortingAlgos.exe
Make sure the assets/ folder (containing Roboto-Regular.ttf) is in the same directory as the executable.
4

Run the Application

Launch the visualizer by running the executable:
SortingAlgos.exe
A window titled “Sorting visualiser - DevBoiAgru” will open, displaying 250 vertical bars representing numbers from 1 to 250.
5

Try Your First Sort

Now let’s visualize a sorting algorithm:
  1. Click the “Shuffle” button (blue, top-left) to randomize the bars
  2. Click the “Bubble sort” button (cyan, second row) to start the algorithm
  3. Watch as the bars are compared and swapped:
    • Red and green highlights show elements being compared
    • Blue highlight appears during the final verification pass
  4. The algorithm completes when all bars are sorted from shortest to tallest
Try clicking “Reverse” to reverse the sorted list, then test a different algorithm like “Quick sort” to compare speeds!

Command-Line Usage

You can control the visualization speed by passing a delay parameter when launching the application:
SortingAlgos.exe <delay>
  • <delay>: Time delay between sorting operations in nanoseconds (default: 1ns)

Examples

# Ultra-fast sorting (10 nanoseconds between operations)
SortingAlgos.exe 10

# Slower visualization for educational purposes (100,000 nanoseconds = 0.1ms)
SortingAlgos.exe 100000

# Very slow, step-by-step visualization (10,000,000 nanoseconds = 10ms)
SortingAlgos.exe 10000000
Setting the delay too low (e.g., 1-10ns) may cause the sort to complete almost instantly, making it hard to observe the algorithm’s behavior. Start with higher values like 100,000+ for learning.

Help Command

To see usage information:
SortingAlgos.exe --help
# or
SortingAlgos.exe -h
This displays:
Command line usage: sortingalgo <delay between operations in nanoseconds>
For example:
    sortingalgos.exe 10
    This will make it so that the hold between each comparision is 10 nanoseconds.

Understanding the Interface

When the application launches, you’ll see:
  • Top row buttons: Shuffle, Reverse, list size controls (+/-), Refresh, and Quit
  • Second row buttons: Six sorting algorithm buttons (Selection, Bubble, Insertion, Quick, Bogo, Stalin)
  • Center display: Current list size (e.g., “250”)
  • Visualization area: Vertical bars representing the numbers to be sorted
The application window is 1080×720 pixels. Bars are positioned with a 50-pixel offset from the edges.

Troubleshooting

If you get an error about missing DLL files:
  • Copy SFML DLLs from vcpkg\installed\x64-windows\bin\ to the same folder as SortingAlgos.exe
  • Required DLLs: sfml-graphics-2.dll, sfml-window-2.dll, sfml-system-2.dll
The application requires Roboto-Regular.ttf in the assets/ folder:
SortingAlgos.exe
assets/
  └── Roboto-Regular.ttf
Ensure this structure is maintained when running the executable.
If Visual Studio can’t find SFML headers:
  1. Verify vcpkg integration: vcpkg integrate install
  2. Check that SFML is installed: vcpkg list
  3. Ensure you’re building for the correct platform (x64)
If you see “Invalid delay input” error:
  • The delay parameter must be a positive integer (no decimals, signs, or letters)
  • Valid: SortingAlgos.exe 100000
  • Invalid: SortingAlgos.exe -50, SortingAlgos.exe 1.5, SortingAlgos.exe slow

What’s Next?

Now that you have the visualizer running, explore these topics:

User Interface Guide

Learn about all the buttons and interactive controls

Algorithm Deep Dives

Understand how each sorting algorithm works under the hood

Build from Source

Explore the build process and compilation details

Contributing

Learn how to contribute improvements to the project

Build docs developers (and LLMs) love