Sorting Algorithm Visualization : Quick Sort
An algorithm like Quicksort algorithm is hard to understand theoretically. We can understand easily by visualizing such kind of algorithms. In this article, a program that visualizes the Quicksort Algorithm has been implemented.
The Graphical User Interface(GUI) is implemented in python using pygame library.
- An array of random values is generated and are drawn as lines(bars) in the window.
- Since the algorithm performs the operation very fast, pygame.time.delay() has been used to slow down the process.
- Assign specific keys for each operation (start sorting, reset bars).
- The actions are performed using
‘pygame.event.get()’method, which stores all the events which user performs.
- Different colors are used to indicate types of bar.
- Green – Unsorted bar
- Blue – Pivot bar
- Orange – Sorted bar
Please make sure to install the pygame library in your system.
Below is the implementation of the above visualizer:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.