🏁 Sorting Race
Watch sorting algorithms race against each other in your terminal!
A beautiful terminal visualization that runs multiple sorting algorithms simultaneously, showing their real-time progress, comparisons, and memory usage.
✨ Features
- 7 Sorting Algorithms racing in parallel
- Real-time Visualization with beautiful TUI
- 4 Fairness Modes to control algorithm execution
- Multiple Data Patterns to test different scenarios
- Live Metrics tracking comparisons, moves, and memory
- Interactive Controls to pause, reset, and explore
🚀 Quick Start
Installation
📦 Pre-built Binaries (Recommended)
Download for your platform from GitHub Releases:
Available Platforms:
- Linux (AMD64, ARM64) -
sorting-race-linux-*.tar.gz
- macOS (Intel, Apple Silicon) -
sorting-race-macos-*.tar.gz
- Windows (AMD64) -
sorting-race-windows-amd64.zip
# Linux/macOS - extract and run
# Windows - extract and run
🦀 Using Cargo
Install from crates.io - requires Rust toolchain:
🔧 From Source
For development or latest unreleased features:
# Clone and build
# Run
💡 Tip: Pre-built binaries are fastest to get started. Use Cargo install if you want automatic updates with
cargo install-update sorting-race
.
Basic Usage
# Run with defaults (50 elements)
# Larger array
# Different data pattern
# Custom fairness mode
🎮 Controls
Key | Action |
---|---|
Space |
Pause/Resume the race |
R |
Reset with new random data |
Q |
Quit application |
🎯 Command Line Options
Array Configuration
-s, --size <N>
- Number of elements to sort (default: 50)-S, --seed <SEED>
- Random seed for reproducible runs-d, --distribution <TYPE>
- Data distribution pattern
Distribution Types
shuffled
- Random order (default)reversed
- Worst case for some algorithmsnearly-sorted
- Best case for adaptive algorithmsfew-unique
- Tests stability with duplicates
Fairness Modes
Comparison Budget (--fair comp
)
Each algorithm gets equal comparison operations per step.
Weighted Fairness (--fair weighted
)
Balance between comparisons (α) and moves (β).
Wall-Time Fairness (--fair walltime
)
Each algorithm gets equal CPU time slices.
Adaptive Fairness (--fair adaptive
)
Dynamically adjusts based on algorithm progress.
📊 The Algorithms
Algorithm | Best Case | Average | Worst Case | Memory |
---|---|---|---|---|
Bubble Sort | O(n) | O(n²) | O(n²) | O(1) |
Insertion Sort | O(n) | O(n²) | O(n²) | O(1) |
Selection Sort | O(n²) | O(n²) | O(n²) | O(1) |
Heap Sort | O(n log n) | O(n log n) | O(n log n) | O(1) |
Merge Sort | O(n log n) | O(n log n) | O(n log n) | O(n) |
Quick Sort | O(n log n) | O(n log n) | O(n²) | O(log n) |
Shell Sort | O(n log n) | O(n^1.3) | O(n²) | O(1) |
🎨 Visual Elements
- Bar Chart - Current array state with color-coded values
- Progress Bars - Completion percentage for each algorithm
- Memory Graph - Real-time memory usage tracking
- Metrics Panel - Live comparisons and moves counter
- Status Text - Current operation for each algorithm
💡 Examples
Compare on Nearly Sorted Data
Watch how Insertion Sort excels on nearly sorted data!
Large Array with Adaptive Fairness
See how the system adapts to give slower algorithms more resources.
Worst Case Scenario
Observe how Quick Sort struggles with reversed data.
Stability Test
Test which algorithms maintain the relative order of equal elements.
🖥️ System Requirements
- OS: Linux, macOS, Windows (x86_64, ARM64)
- Terminal: UTF-8 support with 256 colors
- Size: Minimum 80×24 terminal recommended
- Binary Size: ~2MB (no external dependencies)
- Rust: Only required if building from source
🤝 Contributing
Contributions are welcome! Check out DEVELOPER.md for development setup and guidelines.
📄 License
MIT License - see LICENSE for details.
🙏 Acknowledgments
Built with amazing Rust libraries:
Enjoy watching algorithms race! May the best sort win! 🏆