An interactive web application that visualizes various sorting algorithms with real-time animations and statistics tracking. Built with vanilla JavaScript, HTML, and Tailwind CSS.
- 6 Sorting Algorithms: Bubble Sort, Selection Sort, Insertion Sort, Merge Sort, Quick Sort, and Heap Sort
- Adjustable Array Size: Customize from 10 to 150 elements
- Speed Control: 5 speed levels from Very Slow to Very Fast
- Real-time Statistics: Track comparisons, array accesses, and execution time
- Visual Feedback: Color-coded animations showing comparisons, swaps, and sorted elements
- Dark Theme: Modern, eye-friendly interface with gradient effects
- Educational Info: Algorithm descriptions with time and space complexity
No installation required! Just a modern web browser.
- Clone the repository:
git clone https://github.com/7vignesh/sorting-visualizer.git- Navigate to the project directory:
cd sorting-visualizer- Open
index.htmlin your browser:
# On Windows
start index.html
# On macOS
open index.html
# On Linux
xdg-open index.htmlOr simply double-click the index.html file.
- Select Algorithm: Choose from 6 different sorting algorithms
- Adjust Array Size: Use the slider to set the number of bars (10-150)
- Set Speed: Control animation speed (1-5)
- Generate Array: Click "Generate" to create a new random array
- Start Sorting: Click "Sort" to begin visualization
- Purple/Pink: Unsorted elements
- Yellow: Elements being compared
- Red: Elements being swapped
- Blue: Pivot element (Quick Sort)
- Green: Sorted elements
| Algorithm | Time Complexity | Space Complexity |
|---|---|---|
| Bubble Sort | O(n²) | O(1) |
| Selection Sort | O(n²) | O(1) |
| Insertion Sort | O(n²) | O(1) |
| Merge Sort | O(n log n) | O(n) |
| Quick Sort | O(n log n) avg | O(log n) |
| Heap Sort | O(n log n) | O(1) |
- HTML5: Structure
- CSS3: Styling with custom animations
- Tailwind CSS: Utility-first CSS framework
- JavaScript (ES6+): Logic and interactivity
- Async/Await: Smooth animations
sorting-visualizer/
│
├── index.html # Main HTML file
├── styles.css # Custom CSS styles
├── script.js # JavaScript logic
└── README.md # Project documentation
Each sorting step is animated with color coding to help understand the algorithm's behavior in real-time.
Monitor algorithm efficiency with live statistics:
- Comparisons: Number of element comparisons
- Array Accesses: Total array read/write operations
- Time: Execution time in milliseconds
Works seamlessly across different screen sizes and devices.
Contributions are welcome! Feel free to:
- Fork the project
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is open source and available under the MIT License.
Vignesh
- GitHub: @7vignesh
- Inspired by the need to understand sorting algorithms visually
- Built as a learning project to demonstrate algorithm knowledge
- Thanks to the open-source community
For questions or feedback, feel free to reach out!
⭐ Star this repository if you found it helpful!
