An interactive real-time visualization of the QuickSort algorithm built with C++ and SDL2. Watch as data gets recursively partitioned and sorted with smooth animations and color-coded elements to understand one of the most efficient sorting algorithms.
This project is part of a series of algorithm visualization tools designed to help students and developers understand sorting algorithms through visual representation. QuickSort, known for its exceptional average-case performance, uses a divide-and-conquer strategy that becomes crystal clear when visualized in real-time.
- šReal-time QuickSort visualization with smooth animation
- šColor-coded elements to distinguish pivot, partitions, and sorted sections
- š¬Adjustable animation speed for detailed analysis or quick overview
- šMultiple data set sizes to observe algorithm behavior at different scales
- šStep-by-step breakdown showing pivot selection and partitioning process
- šPerformance metrics display including comparisons and swaps counter
- ā”Interactive controls for pause, reset, and speed adjustment
The visualization demonstrates the key phases of QuickSort:
- šÆ Pivot Selection - Choose an element as the pivot (highlighted in red)
- š Partitioning - Rearrange elements so smaller values are on the left, larger on the right (highlighted in orange)
- š Pivot Placement - Position the pivot in its final sorted location (highlighted in green)
- š Recursive Division - Repeat the process on left and right subarrays (highlighted in blue)
- ā Sorted Elements - Elements in their final position (highlighted in white)
- Best Case O(n log n)
- Average Case O(n log n)
- Worst Case O(n²)
This visualizer helps you understand:
- How pivot selection affects partitioning efficiency
- The recursive nature of QuickSort's divide-and-conquer approach
- Why QuickSort is typically faster than other O(n log n) algorithms in practice
- The impact of different input patterns on algorithm performance
- The relationship between comparisons, swaps, and overall efficiency
- C++ compiler (C++11 or later)
- SDL2 development libraries
- CMake (optional, for building)
Contributions are welcome! Feel free to:
- Report bugs or suggest features via issues
- Submit pull requests to improve the visualization
- Add new pivot selection strategies (median-of-three, random, etc.)
- Enhance the UI or add new features
© 2025 GitHub ⢠Code of Conduct