A terminal-based interactive sorting algorithm visualizer written in C++
![]() |
|---|
| Merge Sort visualization |
![]() |
![]() |
|---|---|
| Selection Sort visualization | Counting Sort visualization |
![]() |
|---|
| With Theory |
-
Selection Sort
-
Insertion Sort
-
Bubble Sort
-
Quick Sort
-
Merge Sort
-
Heap Sort
-
Counting Sort
- C++ compiler with C++20 support (g++, clang++)
- Python 3.x (for the interactive menu)
- Linux/Unix-like environment (or WSL on Windows)
-
Clone the repository:
git clone https://github.com/crypticsaiyan/visusort.git cd visusort -
Build the project:
# Using the installation script (recommended) chmod +x installation.sh ./installation.sh # Or manually g++ -O3 -s $(find . -name "*.cpp") -o main
python3 visusort.py./main <algorithm> <display_theory>Parameters:
<algorithm>: One ofselection,insertion,bubble,quick,merge,heap,counting<display_theory>:1to show theory,0to skip
Examples:
# Run bubble sort with theory explanations
./main bubble 1
# Run quick sort without theory
./main quick 0
# Run merge sort with theory
./main merge 1Example Session:
Enter the length of test array: 5
Enter the values separated by spaces: 64 34 25 12 22
^: Current element being processed*: Element being compared- Red highlighting: Elements being swapped
- Green highlight: Element(s) currently being compared
- Blue highlight: Element(s) actively being processed or manipulated
- Yellow highlight: Element(s) that are sorted and in their final position
- Comparison counter: Real-time count of comparisons made
Note: The visual elements may vary slightly based on the terminal emulator used.
You can adjust the animation speed by modifying the pause_duration value in globals.cpp and recompiling:
- Open
globals.cpp - Change the value of
pause_duration(default is 200ms)- Lower values = faster animation
- Higher values = slower animation
- Recompile using the installation script:
./installation.sh
MIT License
- Small Arrays (< 20 elements): All algorithms perform similarly
- Medium Arrays (20-100 elements): O(n log n) algorithms show clear advantages
- Large Arrays (> 100 elements): Performance differences become very apparent
- Counting Sort: Excellent for arrays with small range of values
Made with ❤️ by crypticsaiyan
⭐ If you found this project useful, please consider giving it a star! ⭐




