An interactive Sorting Algorithm Visualizer that demonstrates how different sorting algorithms work step by step.
Built with a focus on simplicity, clean UI, and educational value β this project helps users see what happens behind the code when arrays get sorted.
π Try it now: https://krishnapschauhan.github.io/sorting-visualizer/
- ποΈ Real-time animation for every sorting step
- βοΈ Adjustable speed and array size
- π Generate new random arrays anytime
- π Color-coded comparisons and swaps
- π» Fully responsive and works in any browser
| Control | Description |
|---|---|
| π² Randomize Array | Generates a new random array of bars to visualize sorting again. |
| π Insertion Sort | Visualizes the insertion sort algorithm β builds the sorted array one element at a time. |
| π Selection Sort | Selects the smallest (or largest) element in each pass and places it in the correct position. |
| π§ Bubble Sort | Repeatedly compares adjacent elements and swaps them if they are in the wrong order. |
| β‘ Quick Sort | Uses the divide-and-conquer approach to partition the array and sort recursively. |
| 𧬠Merge Sort | Splits the array into halves, sorts each half, and merges them in order. |
| π Change Size | Adjusts the number of bars (array size) in the visualization to make sorting more or less detailed. |
| Algorithm | Time Complexity (Avg) | Space Complexity | Stability |
|---|---|---|---|
| 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) | O(log n) | β |
(More algorithms can be added easily!)
- HTML5 β Structure
- CSS3 β Styling, layout, and animations
- JavaScript (ES6) β Sorting logic & visualization
- GitHub Pages β Deployment
- The array is represented as vertical bars.
- When you select an algorithm, each comparison and swap updates the colors and bar heights in real-time.
- Delays are controlled by the selected speed slider to visualize sorting more clearly.
# Clone the repository
git clone https://github.com/krishnapschauhan/sorting-visualizer.git
# Navigate into the project directory
cd sorting-visualizer