A comprehensive web application for visualizing and learning algorithms through interactive step-by-step animations. Built with React, Vite, and Tailwind CSS.
- Sorting Algorithms: Bubble Sort, Selection Sort, Insertion Sort, Merge Sort, Quick Sort, Heap Sort, Shell Sort, Counting Sort, Radix Sort, Bucket Sort, Cocktail Sort, Comb Sort, Gnome Sort, Odd-Even Sort
- Search Algorithms: Binary Search, Linear Search, Jump Search, Interpolation Search, Exponential Search, Ternary Search, Fibonacci Search, Sentinel Search, Two-Pointer Search
- Graph Algorithms: BFS Traversal, DFS Traversal, Dijkstra's Algorithm, Bellman-Ford, Floyd-Warshall, Prim's MST, Kruskal's MST, Topological Sort, Cycle Detection
- Dynamic Programming: 0/1 Knapsack, Longest Common Subsequence, Edit Distance, Coin Change, Matrix Chain Multiplication, Rod Cutting, Longest Increasing Subsequence, Fibonacci DP
- AI DSA Mentor: An intelligent teaching assistant powered by LLaMA 3 (via Groq) to solve doubts, explain code, and recommend data structures.
- Doubt Solver: Get conceptual explanations and real-world analogies.
- Code Explainer: Identification of algorithms and optimization tips for your code snippets.
- DS Recommender: Personalized data structure recommendations based on problem requirements.
- ArrayVisualizer: Bar chart visualizations for sorting and searching algorithms
- GraphVisualizer: Node-edge graph visualizations with grid layout
- DPVisualizer: Table-based visualizations for dynamic programming
- SearchVisualizer: Pointer-based visualizations for search algorithms
- SmartVisualizer: Intelligent routing to appropriate visualizer based on algorithm type
- Step-by-step Animation: Watch algorithms execute step by step
- Speed Control: Adjust animation speed for better understanding
- Custom Input: Provide your own arrays and data
- Random Generation: Generate random test data
- Traversal Order Display: See the exact order of operations
- Shortest Path Highlighting: Visual representation of optimal paths (Dijkstra)
- Algorithm Descriptions: Detailed explanations for each algorithm
- Complexity Analysis: Time and space complexity information
- Interactive Controls: Play, pause, step forward, step backward, reset
- Real-time Messages: Understand what's happening at each step
- Frontend: React 18 with hooks
- Backend (AI): Flask (Python) with Groq SDK
- LLM: LLaMA 3.3 70B (via Groq API)
- Build Tool: Vite for fast development and building
- Styling: Tailwind CSS for modern, responsive design
- Animations: Framer Motion for smooth transitions
- Architecture: Component-based with SmartVisualizer pattern and proxied API routes
src/
βββ algorithms/ # Algorithm implementations
β βββ comprehensiveAlgorithms.js # Central algorithm registry
β βββ comprehensiveSorting.js # Core sorting algorithms
β βββ comprehensiveSearching.js # Core searching algorithms
β βββ additionalSorting.js # Extended sorting algorithms
β βββ additionalSearching.js # Extended searching algorithms
β βββ graph/ # Graph algorithms
β β βββ bfsSteps.js
β β βββ dfsSteps.js
β β βββ dijkstraSteps.js
β β βββ additionalGraphAlgorithms.js # Bellman-Ford, Floyd-Warshall, MST, etc.
β βββ dp/ # Dynamic programming
β βββ knapsackSteps.js
β βββ additionalDPAlgorithms.js # LCS, Edit Distance, Coin Change, etc.
βββ components/ # React components
β βββ SmartVisualizer.jsx # Main visualizer router
β βββ GraphVisualizer.jsx # Graph visualization
β βββ ArrayVisualizer.jsx # Array visualization
β βββ DPVisualizer.jsx # DP table visualization
β βββ SearchVisualizer.jsx # Search visualization
βββ pages/ # Application pages
β βββ Learn.jsx # Main learning interface
β βββ Compare.jsx # Algorithm comparison
β βββ Home.jsx # Landing page
β βββ Experiment.jsx # Python experimentation
βββ engine/ # Core functionality
β βββ stepPlayer.js # Animation controller
β βββ pyodideRunner.js # Python execution
βββ backend/ # AI Mentor API (Flask)
β βββ app.py # Main Flask server
β βββ prompts.py # Structured AI prompts
β βββ requirements.txt # Python dependencies
β βββ .env # API keys (Groq)
- Node.js (version 16 or higher)
- npm or yarn
- Clone the repository:
git clone https://github.com/satyam2006-cmd/AlgoLabX.git
cd AlgoLabX- Install dependencies:
npm install- Start the development server:
npm run dev- Open your browser and navigate to
http://localhost:5173
-
Navigate to the backend directory:
cd backend -
Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install requirements:
pip install -r requirements.txt
-
Configure your API key:
- Create a
.envfile in thebackend/directory. - Add your Groq API key:
GROQ_API_KEY=your_key_here
- Create a
-
Start the backend:
python app.py
npm run build- Navigate to the Learn tab
- Select an algorithm from the dropdown menu
- Choose between:
- Random Array: Generate test data automatically
- Custom Array: Input your own data
- For search algorithms, specify the target value
- Click Play to start the animation
- Use controls to pause, step forward/backward, or reset
- Sorting: Watch bars compare and swap positions
- Searching: See pointers move through the array
- Graphs: Follow node traversal with edge weights
- DP: Observe table filling process
- Bubble Sort: O(nΒ²) - Simple comparison-based sorting
- Selection Sort: O(nΒ²) - Selects minimum element repeatedly
- Insertion Sort: O(nΒ²) - Builds sorted array one element at a time
- Merge Sort: O(n log n) - Divide and conquer approach
- Quick Sort: O(n log n) - Partition-based sorting
- Heap Sort: O(n log n) - Uses heap data structure
- Shell Sort: O(n logΒ² n) - Improved insertion sort with gap sequences
- Counting Sort: O(n+k) - Non-comparison based
- Radix Sort: O(dΓ(n+k)) - Digit by digit sorting
- Bucket Sort: O(n+k) - Distribution-based sorting
- Cocktail Sort: O(nΒ²) - Bidirectional bubble sort
- Comb Sort: O(nΒ²) - Improved bubble sort with shrinking gap
- Gnome Sort: O(nΒ²) - Simple sorting similar to insertion sort
- Odd-Even Sort: O(nΒ²) - Parallel-friendly sorting
- Binary Search: O(log n) - Requires sorted array
- Linear Search: O(n) - Sequential search
- Jump Search: O(βn) - Block-based search
- Interpolation Search: O(log log n) - Position-based search
- Exponential Search: O(log n) - Range-based search
- Ternary Search: O(logβ n) - Divides array into three parts
- Fibonacci Search: O(log n) - Uses Fibonacci numbers to divide array
- Sentinel Search: O(n) - Optimized linear search
- Two-Pointer Search: O(n) - Finds pairs with given sum
- BFS: O(V+E) - Level-order traversal
- DFS: O(V+E) - Depth-order traversal
- Dijkstra: O((V+E) log V) - Single-source shortest path
- Bellman-Ford: O(VE) - Handles negative edge weights
- Floyd-Warshall: O(VΒ³) - All-pairs shortest path
- Prim's MST: O((V+E) log V) - Minimum spanning tree (greedy)
- Kruskal's MST: O(E log E) - Minimum spanning tree (union-find)
- Topological Sort: O(V+E) - Linear ordering of DAG vertices
- Cycle Detection: O(V+E) - Detects cycles in directed graphs
- 0/1 Knapsack: O(nW) - Optimization problem solving
- Longest Common Subsequence: O(mn) - Find longest common subsequence
- Edit Distance: O(mn) - Minimum string transformations
- Coin Change: O(nΓamount) - Minimum coins for amount
- Matrix Chain Multiplication: O(nΒ³) - Optimal parenthesization
- Rod Cutting: O(nΒ²) - Maximize profit by cutting rod
- Longest Increasing Subsequence: O(nΒ²) - Find longest increasing sequence
- Fibonacci DP: O(n) - Computing Fibonacci using DP
The SmartVisualizer component automatically routes to the appropriate visualizer based on algorithm type:
sortingβArrayVisualizersearchingβSearchVisualizergraphβGraphVisualizerdpβDPVisualizer
All algorithms generate a series of steps containing:
- Current state of data structures
- Active elements being processed
- Messages explaining the operation
- Metadata for visualization
- Mobile-friendly interface
- Adaptive layouts for different screen sizes
- Touch-friendly controls
- Implement the algorithm in the appropriate category file
- Generate step data following the established format
- Register the algorithm in
comprehensiveAlgorithms.js - Add the algorithm to the UI dropdown
- Create a new component following the existing pattern
- Add routing logic to
SmartVisualizer - Define the expected data structure for steps
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- React team for the amazing framework
- Vite for the lightning-fast build tool
- Tailwind CSS for the utility-first CSS framework
- Framer Motion for smooth animations
- 70+ files in the codebase
- 18,000+ lines of code
- 40+ algorithms implemented
- 4 specialized visualizers
- Complete step-by-step animations for all algorithms
AlgoLabX - Making algorithms visual and interactive! π
Built with β€οΈ by satyam2006-cmd