Home

JavaScript Data Structures & Algorithms

JavaScript Data Structures Algorithms License

Complete DSA implementation in JavaScript with clear explanations, complexity analysis, and real-world examples. Professional template with modern tooling: testing, documentation, Docker support, and automated CI/CD.

๐Ÿ“š What's Inside

  • 50+ Data Structures - Arrays, Linked Lists, Trees, Graphs, Heaps, and more
  • 100+ Algorithms - Sorting, Searching, Dynamic Programming, Greedy, etc.
  • Time & Space Complexity - Detailed analysis for every solution
  • Comprehensive Testing - 100% test coverage with Vitest
  • Interview Prep - LeetCode patterns and problem-solving strategies
  • Visual Explanations - Diagrams and step-by-step walkthroughs
  • Type-Safe - TypeScript type checking for JavaScript
  • Docker Support - Containerized development and testing

๐ŸŽฏ Perfect For

  • Software engineering interviews (FAANG, startups)
  • Competitive programming (Codeforces, HackerRank, LeetCode)
  • Computer science students
  • Self-taught developers
  • Interview preparation

๐Ÿ“– Topics Covered

Data Structures

  • Arrays & Strings
  • Linked Lists (Singly, Doubly, Circular)
  • Stacks & Queues
  • Trees (Binary, BST, AVL, Red-Black)
  • Graphs (Directed, Undirected, Weighted)
  • Heaps (Min, Max)
  • Hash Tables
  • Tries

Algorithms

  • Sorting (Quick, Merge, Heap, etc.)
  • Searching (Binary, Linear, DFS, BFS)
  • Dynamic Programming
  • Greedy Algorithms
  • Backtracking
  • Divide & Conquer
  • Graph Algorithms (Dijkstra, Bellman-Ford, Floyd-Warshall)
  • String Algorithms (KMP, Rabin-Karp)

๐Ÿ“‹ Prerequisites

  • Node.js: >= 24.12.0 < 25.0.0
  • pnpm: >= 10.0.0 (enforced via preinstall hook)
  • Docker (optional): For containerized development

๐Ÿšฆ Getting Started

# Clone the repository
git clone https://github.com/shonjoydev/dsa-javascript.git

# Navigate to directory
cd dsa-javascript

# Install dependencies (only pnpm is allowed)
pnpm install:pkg

๐Ÿ“ฆ Available Scripts

Development

# Run tests
pnpm test

# Run tests in watch mode
pnpm test:watch

# Run tests with coverage
pnpm test:coverage

# Run documentation server
pnpm docs:dev

Docker Commands

# Run tests once
pnpm docker:test

# Run tests in watch mode
pnpm docker:test:watch

# Run tests with coverage
pnpm docker:test:coverage

# Run docs dev server
pnpm docker:docs

# Run docs in background
pnpm docker:docs:bg

# Stop all services
pnpm docker:down

# Rebuild containers
pnpm docker:build

# Clean up everything
pnpm docker:clean

๐Ÿณ Docker Setup

Using Docker Compose

# Build and run tests
docker-compose up test

# Run tests in watch mode
docker-compose up test-watch

# Run with coverage
docker-compose up test-coverage

# Run documentation server
docker-compose up docs

Manual Docker Commands

# Build the image
docker build -t dsa-javascript .

# Run tests
docker run --rm dsa-javascript

# Run with interactive terminal
docker run -it --rm dsa-javascript

๐Ÿ“ Repository Structure

dsa-javascript/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ arrays/
โ”‚   โ”‚   โ”œโ”€โ”€ two-sum.js
โ”‚   โ”‚   โ”œโ”€โ”€ binary-search.js
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ strings/
โ”‚   โ”‚   โ”œโ”€โ”€ isPalindrome.js
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ linked-lists/
โ”‚   โ”‚   โ”œโ”€โ”€ reverse-linked-list.js
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ trees/
โ”‚   โ”‚   โ”œโ”€โ”€ binary-tree-traversal.js
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ graphs/
โ”‚   โ”‚   โ”œโ”€โ”€ dfs.js
โ”‚   โ”‚   โ”œโ”€โ”€ bfs.js
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ””โ”€โ”€ dynamic-programming/
โ”‚       โ”œโ”€โ”€ fibonacci.js
โ”‚       โ””โ”€โ”€ ...
โ”œโ”€โ”€ tests/                 # Test files
โ”œโ”€โ”€ docs/                  # Documentation
โ”œโ”€โ”€ .github/               # GitHub workflows
โ”œโ”€โ”€ Dockerfile             # Docker configuration
โ”œโ”€โ”€ docker-compose.yml     # Docker Compose configuration
โ”œโ”€โ”€ jsconfig.json          # JavaScript/TypeScript config
โ”œโ”€โ”€ package.json           # Project metadata
โ””โ”€โ”€ README.md             # This file

๐Ÿงช Testing

Tests are written using Vitest.

# Run all tests
pnpm test

# Run specific test file
pnpm test src/arrays/two-sum.test.js

# Run with UI
pnpm test --ui

# Generate coverage report
pnpm test:coverage

๐Ÿ“ Code Quality

  • JSDoc: Comprehensive documentation with examples
  • TypeScript: Type checking for JavaScript files
  • Strict mode: Enabled in jsconfig.json
  • Vitest: Fast unit testing with 100% coverage
  • SonarQube: Docker best practices

๐Ÿค Contributing

Contributions welcome! Please read CONTRIBUTING.md first.

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

Commit Guidelines

  • Use clear and descriptive commit messages
  • Follow conventional commits format (optional)
  • Ensure all tests pass before committing

๐Ÿ“„ License

MIT License - feel free to use for learning and interviews!

๐Ÿ‘ค Author

Shonjoy

๐Ÿ™ Acknowledgments

  • Vitest - Testing framework
  • pnpm - Fast, disk space efficient package manager
  • Docker - Containerization platform

โญ Show Your Support

If this helped you, give it a โญ! It motivates me to add more content.

๐Ÿ“ž Support

For support, email your-email@example.com or open an issue in the repository.


โฌ† Back to Top

Made with โค๏ธ by Shonjoy