A simple and responsive sorting algorithm visualizer built with Python and the Tkinter standard library. This tool allows you to watch various sorting algorithms in real-time, helping you understand how they work step-by-step.
(After you run the program, take a screenshot and upload it to your repository, then replace the text above with the link)
- Multiple Algorithms: Compare several popular sorting algorithms:
- Introsort
- Heapsort
- Insertion Sort
- Bubble Sort
- Interactive Controls:
- Algorithm Selection: Choose your algorithm from a dropdown menu.
- Array Size: Use a slider to set the number of items to sort (from 10 to 200).
- Speed: Control the visualization speed with a delay slider (from 1ms to 500ms).
- Real-time Visualization: Bars are color-coded to show their status:
- Sky Blue: Default
- Orange: Being compared
- Purple: Being swapped
- Red: Pivot element (for Introsort/Quicksort)
- Green: Sorted
- Modern UI: Uses ttk themed widgets for a cleaner look than standard Tkinter.
This project uses only Python's standard libraries, so no external packages are needed.
-
Clone the repository: bash git clone https://github.com/YOUR_USERNAME/YOUR_REPOSITORY_NAME.git cd YOUR_REPOSITORY_NAME
-
Ensure you have Python 3: This program requires tkinter, which is included with most Python 3 installations. If you don't have it, you may need to install it: bash
sudo apt-get install python3-tk
sudo dnf install python3-tkinter
-
Run the script: bash python visualizer.py
- Generate Array: Click "Generate New Array" to create a new random list of numbers. The size is based on the "Array Size" slider.
- Select Algorithm: Choose an algorithm from the dropdown.
- Adjust Speed: Set the delay between steps. A smaller delay is faster.
- Start Sort: Click "Start Sort" to begin the visualization. The controls will be disabled until the sort is complete.
Enjoy comparing the algorithms!