Made by CharlieIQ
Website link: https://charlieiq.github.io/algorithm-visualizer/
A React + TypeScript web app that visualizes sorting algorithms with animations, step-by-step controls, and a code editor for custom algorithms.
The site includes a wide variety of sorting algorithms, organized into categories:
- Efficient Algorithms (O(n log n)): Fast sorts like Quick Sort, Merge Sort, Heap Sort, and Tim Sort.
- Simple Algorithms (O(n²)): Classic sorts such as Bubble Sort, Selection Sort, and Insertion Sort.
- Improved Simple Algorithms: Enhanced versions of basics, including Shell Sort, Comb Sort, and Cocktail Sort.
- Specialized Algorithms: Non comparison sorts like Counting Sort, Radix Sort, and Bucket Sort for specific data types.
- Funny Algorithms: Algorithms that I found funny like Gnome Sort, Pancake Sort, Bogo Sort, and more.
- Node.js (version 16 or higher)
- npm or yarn package manager
-
Clone the repository
git clone https://github.com/CharlieIQ/algorithm-visualizer.git cd algorithm-visualizer -
Install dependencies
npm install
-
Start the development server
npm run dev
-
Open your browser
Navigate to http://localhost:5173/
When you first open the application, you'll see:
- Header: Title and description of the app
- Main Panel: Array visualization, controls, and code editor
- Sidebar: Algorithm selection panel
- Click the "Generate Random" button in the top-right of the visualization panel
- This creates a new array with 15 random elements (values 5-85)
- Look at the input fields below each bar in the visualization
- Click on any input field and type a new number (1-100)
- The bar will update in real-time to reflect your changes
-
Look at the Algorithm Library panel on the right sidebar
-
Search algorithms using the search bar at the top
-
Filter by category using the filter buttons:
- All: View all 12 algorithms
- Efficient: O(n log n) algorithms for production use
- Simple: O(n²) algorithms great for learning
- Improved: Enhanced versions of simple algorithms
- Unusual: Educational and interesting algorithms
-
Click on any algorithm card to select it - the card will highlight with a blue border
-
Use the info and code buttons:
- ℹ️ Info button: Shows detailed explanation, complexity analysis, and when to use the algorithm
- View Code button: Shows the complete JavaScript implementation
Info Button (ℹ️): Click the blue info button on any algorithm to see:
- Detailed description of how the algorithm works
- Time and space complexity explanation
- Step-by-step breakdown of the algorithm's approach
- When and why you'd use this algorithm
- Quick access to try the algorithm or view its code
- Play: Start the sorting animation
- Pause: Stop the animation at the current step
- Reset: Go back to the first step of the algorithm
- ← Step: Go backward one step in the algorithm
- Step →: Go forward one step in the algorithm
- Use the Speed dropdown to adjust animation timing:
- Slow: 1000ms between steps
- Normal: 500ms between steps
- Fast: 250ms between steps
- Very Fast: 100ms between steps
- 🔵 Blue bars: Default/unsorted elements
- 🟡 Yellow bars: Elements currently being compared
- 🔴 Red bars: Elements being swapped
- 🟢 Green bars: Elements in their final sorted position
- Watch the blue information box below the visualization
- It shows the current step number and describes what's happening
- Example: "Comparing elements at positions 2 and 3: 45 vs 23"
- Scroll down to the Custom Algorithm section
- Insert Template: Click this button to get a basic sorting algorithm template
- Adjust Height: Use the height dropdown to make the editor larger/smaller (Small, Medium, Large, Extra Large)
- Write Your Code:
- Your function must be named
customSort - It should take an array parameter:
function customSort(arr) - Return the sorted array
- Example:
function customSort(arr) { // Your algorithm here return arr.sort((a, b) => a - b); }
- Your function must be named
- Run Code: Click the "Run Code" button to execute your algorithm
- The visualization will update to show your sorted result
- Select any preset algorithm (Step 3)
- Click the ℹ️ info button to learn about the algorithm in detail
- Click "View Code" to see the implementation
- Study the code in the modal that appears
- Close the modal and try the algorithm with the controls
- Watch step-by-step to understand how the code translates to visual steps
- React 18
- TypeScript 5
- Vite
- Tailwind CSS 3.3
- Modern JavaScript
Build with love, Copilot, and lots of LeetCode practice