A professional, interactive visualization tool for understanding and comparing sorting algorithms in real-time.
- Real-time animation of sorting algorithms
- Color-coded operations:
- Red: Comparisons
- Green: Swaps
- Yellow: Write operations
- Adjustable speed control for viewing at your own pace
- Array size customization (10-200 elements)
- Live metrics display:
- Number of comparisons
- Number of swaps
- Number of write operations
- Total operation count
- Elapsed time
- Real-time status updates
- Bubble Sort - O(n²) - Simple but inefficient
- Selection Sort - O(n²) - Minimal swaps
- Insertion Sort - O(n²) average, O(n) best - Efficient for small arrays
- Merge Sort - O(n log n) - Divide & conquer
- Quick Sort - O(n log n) average, O(n²) worst - Practical choice
- Heap Sort - O(n log n) - In-place sorting
- Compare performance of all algorithms
- Test with different array sizes
- Generate performance reports
- Identify the fastest and slowest algorithms
Sorting/
├── visualizer.py # Main GUI application
├── algorithms.py # Sorting algorithm implementations
├── benchmark.py # Performance benchmarking tool
├── requirements.txt # Python dependencies
└── README.md # This file
- Python 3.6+
- tkinter (included with most Python installations)
python visualizer.pypython benchmark.pyEach algorithm yields Step objects with information about:
- Type: compare, swap, overwrite, complete, done
- Indices: positions being accessed
- Value: value being written (for overwrites)
- Description: human-readable operation description
- Select an algorithm from the dropdown
- Choose array size (or generate new random array)
- Adjust animation speed
- Click "Start" to begin visualization
- Watch real-time statistics update
- "Pause" to freeze the animation
- "Reset" to start over
✅ Type Hints - Full type annotations for better IDE support
✅ Documentation - Comprehensive docstrings and comments
✅ Clean Code - Follows PEP 8 style guidelines
✅ Efficient - Optimized algorithm implementations
✅ Professional UI - Modern tkinter interface
✅ Error Handling - Robust exception management
| Algorithm | Best | Average | Worst | Space |
|---|---|---|---|---|
| Bubble Sort | O(n) | O(n²) | O(n²) | O(1) |
| Selection Sort | O(n²) | O(n²) | O(n²) | O(1) |
| Insertion Sort | O(n) | O(n²) | O(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) |
| Heap Sort | O(n log n) | O(n log n) | O(n log n) | O(1) |
This project helps you understand:
- How different sorting algorithms work
- Time and space complexity trade-offs
- Visual difference between algorithm approaches
- Performance characteristics in practice
- Generator functions in Python
- Professional GUI design with tkinter
This project demonstrates:
- 🎓 Data Structures & Algorithms knowledge
- 💻 GUI Development with tkinter
- 📈 Performance Analysis and optimization
- 🔧 Code Quality with type hints and documentation
- 🎨 UI/UX Design principles
- 📊 Benchmarking and metrics tracking
- ⚙️ Software Engineering best practices
- Additional algorithms (Radix Sort, Counting Sort, etc.)
- Sound effects for operations
- Export statistics to CSV
- Comparison mode (run multiple algorithms side-by-side)
- Dark/Light theme toggle
- Array input from file
- Step-by-step debugging mode
Created as an educational project for learning data structures and algorithms.
Free to use for educational purposes.
Happy Sorting! 🎉