Skip to content

krishnapschauhan/sorting-visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎨 Sorting Visualizer

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.


πŸš€ Live Demo

πŸ”— Try it now: https://krishnapschauhan.github.io/sorting-visualizer/


🧠 Features

  • 🎞️ 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

🧩 Controls Overview

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.

πŸ“š Algorithms Implemented

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!)


πŸ› οΈ Tech Stack

  • HTML5 β†’ Structure
  • CSS3 β†’ Styling, layout, and animations
  • JavaScript (ES6) β†’ Sorting logic & visualization
  • GitHub Pages β†’ Deployment


πŸ’‘ How It Works

  1. The array is represented as vertical bars.
  2. When you select an algorithm, each comparison and swap updates the colors and bar heights in real-time.
  3. Delays are controlled by the selected speed slider to visualize sorting more clearly.

🧰 Setup Instructions

πŸ”Ή Run Locally

# Clone the repository
git clone https://github.com/krishnapschauhan/sorting-visualizer.git

# Navigate into the project directory
cd sorting-visualizer

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published