Skip to content

kckDeepak/dsa-algorithm-visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฏ DSA Algorithm Visualizer

A beautiful, interactive web platform for visualizing Data Structures and Algorithms. Watch algorithms come to life with stunning animations, step-by-step breakdowns, and comprehensive explanations.

DSA Visualizer Banner JavaScript HTML5 CSS3

โœจ Features

  • ๐ŸŽจ Modern UI/UX - Sleek dark theme with glassmorphism effects and smooth animations
  • โฏ๏ธ Full Playback Control - Play, pause, step forward/backward, and scrub through algorithm execution
  • ๐ŸŽš๏ธ Adjustable Speed - Control animation speed from 0.25x to 4x
  • ๐Ÿ“Š Real-time Stats - Track moves, comparisons, and current step
  • ๐Ÿ“š Comprehensive Explanations - Each algorithm includes overview, step-by-step guide, pseudocode, and real-world applications
  • ๐Ÿ” Search & Filter - Quickly find algorithms by name or category
  • ๐Ÿ“ฑ Responsive Design - Works on desktop and tablet devices
  • โŒจ๏ธ Keyboard Shortcuts - Space to play/pause, arrow keys to step through

๐Ÿงฎ Algorithms Included

Sorting

Algorithm Time Complexity Space Complexity
Merge Sort O(n log n) O(n)
Quick Sort O(n log n) avg O(log n)

Pathfinding

Algorithm Description
Dijkstra's Algorithm Find shortest paths in weighted graphs
A Pathfinding* Intelligent pathfinding with heuristics
Graph Traversal (BFS/DFS) Explore graphs systematically

Backtracking

Algorithm Description
Tower of Hanoi Classic recursive disk-moving puzzle
N-Queens Problem Place N queens without conflicts
Sudoku Solver Solve puzzles with backtracking

Trees

Algorithm Description
Binary Search Tree Insert, search, and traverse BST operations

Dynamic Programming

Algorithm Time Complexity Space Complexity
Longest Common Subsequence (LCS) O(m ร— n) O(m ร— n)

String Algorithms

Algorithm Time Complexity Space Complexity
KMP String Matching O(n + m) O(m)

๐Ÿš€ Getting Started

Prerequisites

  • Node.js (for local development server)
  • Modern web browser (Chrome, Firefox, Edge, Safari)

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/dsa-algorithm-visualizer.git
    cd dsa-algorithm-visualizer
  2. Start the development server

    npx serve frontend -l 5000
  3. Open in browser

    http://localhost:5000
    

๐Ÿ“ Project Structure

dsa-algorithm-visualizer/
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ index.html              # Homepage
โ”‚   โ”œโ”€โ”€ algorithm.html          # Algorithm visualization page
โ”‚   โ”œโ”€โ”€ css/
โ”‚   โ”‚   โ”œโ”€โ”€ styles.css          # Main styles
โ”‚   โ”‚   โ”œโ”€โ”€ algorithm.css       # Algorithm page styles
โ”‚   โ”‚   โ””โ”€โ”€ animations.css      # Animation utilities
โ”‚   โ””โ”€โ”€ js/
โ”‚       โ”œโ”€โ”€ main.js             # Homepage logic
โ”‚       โ”œโ”€โ”€ algorithms/         # Algorithm implementations
โ”‚       โ”‚   โ”œโ”€โ”€ towerOfHanoi.js
โ”‚       โ”‚   โ”œโ”€โ”€ nQueens.js
โ”‚       โ”‚   โ”œโ”€โ”€ mergeSort.js
โ”‚       โ”‚   โ”œโ”€โ”€ quickSort.js
โ”‚       โ”‚   โ”œโ”€โ”€ dijkstra.js
โ”‚       โ”‚   โ”œโ”€โ”€ aStar.js
โ”‚       โ”‚   โ”œโ”€โ”€ bst.js
โ”‚       โ”‚   โ”œโ”€โ”€ sudoku.js
โ”‚       โ”‚   โ”œโ”€โ”€ kmp.js
โ”‚       โ”‚   โ”œโ”€โ”€ graphTraversal.js
โ”‚       โ”‚   โ””โ”€โ”€ lcs.js
โ”‚       โ”œโ”€โ”€ visualizers/        # Visualization components
โ”‚       โ”‚   โ”œโ”€โ”€ tower-of-hanoi.js
โ”‚       โ”‚   โ”œโ”€โ”€ n-queens.js
โ”‚       โ”‚   โ”œโ”€โ”€ merge-sort.js
โ”‚       โ”‚   โ”œโ”€โ”€ quick-sort.js
โ”‚       โ”‚   โ”œโ”€โ”€ dijkstra.js
โ”‚       โ”‚   โ”œโ”€โ”€ a-star.js
โ”‚       โ”‚   โ”œโ”€โ”€ bst.js
โ”‚       โ”‚   โ”œโ”€โ”€ sudoku.js
โ”‚       โ”‚   โ”œโ”€โ”€ kmp.js
โ”‚       โ”‚   โ”œโ”€โ”€ graph-traversal.js
โ”‚       โ”‚   โ””โ”€โ”€ lcs.js
โ”‚       โ””โ”€โ”€ utils/
โ”‚           โ””โ”€โ”€ animator.js     # Animation controller
โ””โ”€โ”€ README.md

๐ŸŽฎ Usage

Homepage

  • Browse available algorithms organized by category
  • Use the search bar to find specific algorithms
  • Filter by category (Sorting, Pathfinding, Backtracking, etc.)
  • Click on any algorithm card to view its visualization

Visualization Page

  • Play/Pause - Start or stop the animation
  • Step Forward/Back - Move through algorithm steps manually
  • Reset - Return to initial state
  • Speed Slider - Adjust animation speed
  • Progress Bar - Click anywhere to jump to that step
  • Tabs - Switch between Overview, Steps, Applications, and Code

Keyboard Shortcuts

Key Action
Space Play/Pause
โ† Step backward
โ†’ Step forward
R Reset

๐Ÿ› ๏ธ Adding New Algorithms

1. Create the Algorithm Class

Create a new file in frontend/js/algorithms/:

// frontend/js/algorithms/myAlgorithm.js
export class MyAlgorithm {
  constructor() {
    this.states = [];
  }
  
  // Your algorithm logic here
  solve() {
    this.states = [];
    // Add states as algorithm progresses
    this.states.push({
      // State data for visualization
      description: 'Step description'
    });
  }
}

export default MyAlgorithm;

2. Create the Visualizer

Create a new file in frontend/js/visualizers/:

// frontend/js/visualizers/my-algorithm.js
import { MyAlgorithm } from '../algorithms/myAlgorithm.js';
import { AnimationController } from '../utils/animator.js';

const info = {
  title: 'My Algorithm',
  description: '...',
  overview: '...',
  steps: '...',
  applications: '...',
  code: '...'
};

let algorithm, animator, canvas, ctx;
let states = [], currentState = null;

export function init() {
  setupDOM();
  setupControls();
  setupAlgorithm();
  setupCanvas();
}

// Implement setupDOM, setupControls, setupAlgorithm, setupCanvas, draw, etc.

export default { init };

3. Register the Algorithm

  1. Add to the visualizers mapping in algorithm.html
  2. Add to the algorithms array in main.js

๐ŸŽจ Customization

Colors

Edit the CSS custom properties in styles.css:

:root {
  --color-primary: #3b82f6;
  --color-accent: #8b5cf6;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-bg-primary: #0f172a;
  --color-bg-secondary: #1e293b;
}

Animation Speed

Adjust the step duration in each visualizer's setupAlgorithm():

animator.stepDuration = 500; // milliseconds between steps

๐Ÿค Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-algorithm)
  3. Commit your changes (git commit -m 'Add amazing algorithm')
  4. Push to the branch (git push origin feature/amazing-algorithm)
  5. Open a Pull Request

Ideas for Contribution

  • Add new algorithms (Heap Sort, Bellman-Ford, Floyd-Warshall, etc.)
  • Improve visualizations
  • Add mobile responsiveness
  • Add dark/light theme toggle
  • Add algorithm comparison mode
  • Add export/share functionality

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Inspiration from various algorithm visualization platforms
  • Icons and design influenced by modern UI trends
  • Built with vanilla JavaScript, HTML5 Canvas, and CSS3

Made with โค๏ธ for learning algorithms

Back to Top โฌ†๏ธ

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors