JavaScript Data Structures & Algorithms
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.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - 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
- GitHub: @shonjoydev
๐ 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.
Made with โค๏ธ by Shonjoy