An interactive web application for visualizing algorithms and data structures, built with SvelteKit 5 and TypeScript. This project provides real-time visual demonstrations of Big O complexity, sorting algorithms, and pathfinding algorithms.
- Interactive Algorithm Comparison: Visualize and compare time complexity of different algorithms
- Real-time Performance Tracking: Measure actual execution time using Web Workers
- Supported Complexities:
- O(1) - Constant time
- O(log n) - Logarithmic time
- O(n) - Linear time
- O(n log n) - Linearithmic time
- O(nΒ²) - Quadratic time
- O(nΒ³) - Cubic time
- O(2βΏ) - Exponential time
- O(n!) - Factorial time
- Dynamic Charts: Visualize algorithm performance with Chart.js
- Predefined Examples: Auto-play feature to demonstrate all algorithms
- Bubble Sort: O(nΒ²) comparison-based sorting
- Selection Sort: O(nΒ²) in-place sorting
- Insertion Sort: O(nΒ²) adaptive sorting
- Merge Sort: O(n log n) divide-and-conquer
- Quick Sort: O(n log n) efficient partitioning
- Visual Bars: Real-time animated bar chart representation
- Keyboard Controls: Quick access with keyboard shortcuts
- Dijkstra's Algorithm: Shortest path with weighted edges
- A Algorithm*: Heuristic-based pathfinding
- Breadth-First Search (BFS): Unweighted shortest path
- Depth-First Search (DFS): Graph traversal exploration
- Interactive Grid: Click to create walls/obstacles
- Drag & Drop: Paint walls by dragging
- Grid Sizes: Tiny (10Γ10) to Huge (70Γ150)
- Save/Load: Persist grid configurations locally
- Node.js 18+ or Bun
- npm, pnpm, or bun package manager
# Clone the repository git clone <repository-url> cd algo # Install dependencies npm install # or bun installStart the development server:
npm run dev # or bun run dev # Open in browser npm run dev -- --openThe application will be available at http://localhost:5173
npm run buildPreview the production build:
npm run preview- Framework: SvelteKit 5 with Svelte 5 runes
- Language: TypeScript
- Styling: Tailwind CSS 4 + DaisyUI 5
- Charts: Chart.js 4.3
- Math: Math.js 14
- Code Highlighting: svelte-highlight
- Markdown: MDsveX
- Deployment: Vercel Adapter
- Build Tool: Vite 6
algo/ βββ src/ β βββ components/ # Reusable UI components β β βββ BigOChart.svelte β β βββ BigOOutputChart.svelte β β βββ Highlighter.svelte β β βββ KeyboardHandler.svelte β β βββ loading/ β β βββ navbars/ β βββ data/ # Data structures and algorithm logic β β βββ big-o.ts # Big O algorithm implementations β β βββ sort.ts # Sorting algorithms β β βββ path.ts # Pathfinding utilities β β βββ pq.ts # Priority Queue implementation β β βββ q.ts # Queue implementation β β βββ state.svelte.ts # Svelte 5 state management β β βββ swap.ts # Array swap utility β βββ services/ # Background services β β βββ worker.ts # Web Worker manager β β βββ background.ts # Background task handler β βββ routes/ # SvelteKit routes β β βββ +page.svelte # Big O visualization page β β βββ sort/ # Sorting algorithms page β β βββ path/ # Pathfinding page β βββ app.css # Global styles βββ static/ # Static assets βββ package.json βββ svelte.config.js βββ tailwind.config.js βββ tsconfig.json βββ vite.config.ts - Alt + R: Randomize array
- Ctrl + Space: Play animation
- Delete: Stop animation
- Alt + S: Set start point
- Alt + E: Set end point
- Alt + R: Random obstacles
- Ctrl + Space: Play algorithm
- Ctrl + S: Save grid
- Ctrl + L: Load grid
- Delete: Clear results
- Shift + Delete: Reset grid
Heavy computational tasks run in background threads to prevent UI blocking, allowing smooth visualization even with large input sizes (1B+ operations).
Modern reactive state management using Svelte 5's new runes API ($state, $derived, $effect).
Custom implementations for efficient pathfinding algorithms (Dijkstra, A*).
Asynchronous rendering with setTimeout for smooth, step-by-step algorithm visualization.
This project is open source and available under the MIT License.
Contributions, issues, and feature requests are welcome!
