An interactive algorithm visualizer for engineering students to understand algorithms step-by-step through beautiful animations.
| Algorithm | Time Complexity (Average) | Space Complexity |
|---|---|---|
| Bubble Sort | O(nΒ²) | O(1) |
| Merge Sort | O(n log n) | O(n) |
| Quick Sort | O(n log n) | O(log n) |
| Algorithm | Time Complexity | Space Complexity |
|---|---|---|
| Binary Search | O(log n) | O(1) |
| Algorithm | Time Complexity | Space Complexity |
|---|---|---|
| Breadth First Search (BFS) | O(V + E) | O(V) |
| Depth First Search (DFS) | O(V + E) | O(V) |
| Dijkstra's Algorithm | O(E log V) | O(V) |
| Bellman-Ford Algorithm | O(VE) | O(V) |
| Floyd-Warshall Algorithm | O(VΒ³) | O(VΒ²) |
| Prim's Algorithm | O(E log V) | O(V) |
| Kruskal's Algorithm | O(E log E) | O(V) |
- Step-by-step Visualization: Watch algorithms execute one step at a time
- Speed Control: Adjust playback speed from Very Slow to Turbo
- Play/Pause/Resume: Control the visualization playback
- Previous/Next Step: Navigate through algorithm steps manually
- Reset: Start over with fresh data
- Custom Input:
- Sorting: Adjustable array size, random generation, pre-sorted, reverse-sorted
- Binary Search: Custom target value
- Graph: Selectable start/end nodes
- Pseudocode Panel: View algorithm pseudocode with highlighted active lines
- Explanation Text: Real-time descriptions of what's happening at each step
- Dark Mode: Modern UI with dark/light theme toggle
- Node.js (v18 or higher)
- npm or yarn
-
Clone the repository
git clone https://github.com/yourusername/algo-visualizer.git cd algo-visualizer -
Install dependencies
npm install
-
Start the development server
npm run dev
-
Open in browser Navigate to
http://localhost:5173
npm run buildThe build output will be in the dist/ folder.
algo-visualizer/
βββ public/
βββ src/
β βββ algorithms/ # Pure algorithm logic
β β βββ bubbleSort.js
β β βββ mergeSort.js
β β βββ quickSort.js
β β βββ binarySearch.js
β β βββ graphAlgorithms.js
β βββ components/ # React UI components
β β βββ Controls.jsx
β β βββ SortingBoard.jsx
β β βββ GraphBoard.jsx
β β βββ Navbar.jsx
β β βββ PseudocodePanel.jsx
β βββ hooks/ # Custom React hooks
β β βββ useAlgoPlayer.jsx
β βββ utils/ # Utility functions
β β βββ helpers.js
β βββ App.jsx
β βββ main.jsx
β βββ index.css
βββ package.json
βββ tailwind.config.js
βββ vite.config.js
The core innovation of AlgoVision is the Trace/Snapshot Pattern:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ALGORITHM EXECUTION β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Algorithm Function β
β β β
β β Run instantly, generate all steps β
β βΌ β
β βββββββββββββββ β
β β Trace Array β Each element is a "snapshot" β
β βββββββββββββββ containing complete state β
β β Step 0 β - Array/Graph state β
β β Step 1 β - Comparison indices β
β β Step 2 β - Swap operations β
β β ... β - Current line of pseudocode β
β β Step N β - Description text β
β βββββββββββββββ β
β β
β Playback Engine (useAlgoPlayer hook) β
β β β
β β Simply plays back the trace β
β β like a video β
β βΌ β
β βββββββββββββββ β
β β UI State β React renders current step β
β βββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Benefits:
- β True Pause: Just stop the step counter
- β Rewind: Simply decrease the step counter
- β Speed Control: Change the interval duration
- β Smooth Animation: All computation happens upfront
- β Time Travel: Jump to any step instantly
- Create a new file in
src/algorithms/:
// src/algorithms/newSort.js
export const generateNewSort = (array) => {
const trace = [];
const arr = [...array];
// Initial state
trace.push({
array: [...arr],
compare: [],
swap: [],
sorted: [],
desc: "Starting New Sort",
codeLine: 0,
});
// Your algorithm here...
// Push snapshots to trace at each interesting step
// Final state
trace.push({
array: [...arr],
compare: [],
swap: [],
sorted: [...Array(arr.length).keys()],
desc: "Sort Complete!",
codeLine: 10,
});
return trace;
};
export const newSortPseudocode = ["START: ...", "...", "END: Array sorted"];- Import and add to
App.jsx:
import { generateNewSort, newSortPseudocode } from "./algorithms/newSort";
// Add to ALGORITHM_CATEGORIES.sorting
// Add to pseudocode switch statementGraph algorithms follow a similar pattern but work with the graph object structure:
trace.push({
graph: { nodes: [...graph.nodes], edges: [...graph.edges] },
visited: [...visited],
highlight: [currentNode],
edgesHighlight: [{ from: current, to: neighbor }],
distances: { ...distances },
parentMap: { ...parentMap },
desc: "Description of current step",
codeLine: 1,
});This project helps students understand:
- Algorithm Fundamentals: How basic sorting and search algorithms work
- Time Complexity: Visual difference between O(nΒ²), O(n log n), O(log n), O(VE), and O(VΒ³)
- Data Structure Traversal: How BFS/DFS explore graphs differently
- Shortest Path: How Dijkstra's, Bellman-Ford, and Floyd-Warshall find optimal paths in weighted graphs
- Minimum Spanning Tree: How Prim's and Kruskal's algorithms build optimal spanning trees
- Visual Debugging: Step through algorithms to understand each operation
| Technology | Purpose |
|---|---|
| React 18 | UI component library |
| Vite 5 | Fast build tool and dev server |
| TailwindCSS 3 | Utility-first styling with dark mode |
| Framer Motion | Smooth animations for bars and nodes |
| Lucide React | Beautiful icon set |
| ESLint | Code linting |
MIT License - feel free to use for learning and teaching!
Contributions are welcome! Please feel free to submit a Pull Request.
Built for Engineering Students
