# trekhleb/javascript-algorithms

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/trekhleb-javascript-algorithms).**

196,089 stars · 31,052 forks · JavaScript · MIT

## Links

- GitHub: https://github.com/trekhleb/javascript-algorithms
- awesome-repositories: https://awesome-repositories.com/repository/trekhleb-javascript-algorithms.md

## Topics

`algorithm` `algorithms` `computer-science` `data-structures` `interview` `interview-preparation` `javascript` `javascript-algorithms`

## Description

This repository is a comprehensive collection of data structures and algorithms implemented in JavaScript, designed primarily as an educational resource for computer science study and technical interview preparation. It provides modular implementations of fundamental programming concepts, allowing developers to explore algorithmic logic and data organization through self-contained, verifiable code examples.

The library distinguishes itself by pairing every implementation with formal Big O notation, providing predictable insights into time and space scaling requirements. Each algorithm is structured around established computational paradigms—such as dynamic programming, greedy strategies, and backtracking—and is verified against a suite of automated unit tests to ensure logical correctness and consistent behavior.

The project covers a broad capability surface, including graph traversal, search and sorting strategies, string analysis, and mathematical operations. It also features specialized utilities for cryptography, probabilistic data processing, machine learning classification, and image manipulation. These components are organized into standardized interfaces to facilitate comparison and integration.

## Tags

### Data & Databases

- [Data Structure Implementations](https://awesome-repositories.com/f/data-databases/data-structure-implementations.md) — Provides modular implementations of fundamental data structures like linked lists, trees, and heaps. ([source](https://cdn.jsdelivr.net/gh/trekhleb/javascript-algorithms@master/README.md))
- [Graph Traversal Strategies](https://awesome-repositories.com/f/data-databases/graph-computing-systems/graph-processing/graph-traversal-strategies.md) — Navigates complex data structures to identify paths and visit nodes using systematic search techniques. ([source](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/uncategorized))

### Development Tools & Productivity

- [Algorithm Libraries](https://awesome-repositories.com/f/development-tools-productivity/algorithm-libraries.md) — Provides a comprehensive collection of algorithms and data structures implemented in JavaScript for educational and interview preparation.

### Education & Learning Resources

- [Computer Science Fundamentals](https://awesome-repositories.com/f/education-learning-resources/computer-science-fundamentals.md) — Serves as a comprehensive educational repository of fundamental computer science concepts and algorithmic implementations.
- [Computer Science Education](https://awesome-repositories.com/f/education-learning-resources/technical-domain-education/computer-science-education.md) — Serves as a comprehensive educational resource for learning data structures and algorithms through modular code.
- [Data Structure Implementations](https://awesome-repositories.com/f/education-learning-resources/data-structure-implementations.md) — Implements fundamental data structures like trees, heaps, and hash tables for educational study and technical interview preparation.
- [Technical Interview Preparation](https://awesome-repositories.com/f/education-learning-resources/technical-interview-preparation.md) — Provides practice materials for core computer science concepts to prepare for technical coding interviews.
- [Algorithm Complexity References](https://awesome-repositories.com/f/education-learning-resources/developer-documentation-references/programming-language-references/algorithm-complexity-references.md) — Provides formal time and space complexity annotations for all implemented algorithms to aid in performance analysis.
- [Algorithmic Problem Solving](https://awesome-repositories.com/f/education-learning-resources/technical-domain-education/computer-science-education/algorithmic-problem-solving.md) — Applies established paradigms to solve complex computational problems in graph traversal and optimization.
- [Searching Algorithms](https://awesome-repositories.com/f/education-learning-resources/educational-resources/algorithms-theory-academics/algorithm-data-structure-guides/searching-algorithms.md) — Implements binary search to locate target values in sorted collections with logarithmic time complexity. ([source](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/search))
- [Search Algorithms](https://awesome-repositories.com/f/education-learning-resources/search-algorithms.md) — Implements interpolation search to optimize lookup speeds for uniformly distributed data. ([source](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/search))

### Scientific & Mathematical Computing

- [Combinatorial Optimization Problems](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/algorithms-and-complexity/algorithms/algorithmic-problems/combinatorial-optimization-problems.md) — Provides implementations for solving complex combinatorial optimization problems like pathfinding and resource allocation. ([source](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/uncategorized))
- [Big O Notations](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/algorithms-and-complexity/algorithm-analysis/big-o-notations.md) — Includes formal Big O notation for every algorithm to provide predictable insights into time and space complexity.
- [Complexity Analysis](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/algorithms-and-complexity/algorithms/computational-complexity/complexity-analysis.md) — Evaluates and documents the computational complexity of algorithms to provide insights into scaling behavior. ([source](https://cdn.jsdelivr.net/gh/trekhleb/javascript-algorithms@master/README.md))
- [Sorting](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/algorithms-and-complexity/algorithms/sorting.md) — Provides various sorting algorithm implementations to organize data collections efficiently. ([source](https://cdn.jsdelivr.net/gh/trekhleb/javascript-algorithms@master/README.md))
- [Mathematical Sequences](https://awesome-repositories.com/f/scientific-mathematical-computing/mathematical-algorithms/mathematical-sequences.md) — Calculates values for recursive and iterative mathematical sequences to demonstrate numerical processing logic. ([source](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/uncategorized))
- [Mathematical Libraries](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/mathematical-libraries-and-utilities/mathematical-libraries.md) — Provides implementations for complex mathematical operations including prime factorization and matrix manipulation. ([source](https://cdn.jsdelivr.net/gh/trekhleb/javascript-algorithms@master/README.md))
- [Palindromic Sequence Analyzers](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/algorithms-and-complexity/string-algorithms/palindromic-sequence-analyzers.md) — Provides algorithmic implementations to detect and validate palindromic symmetry in strings. ([source](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string))

### Part of an Awesome List

- [Algorithm Resources](https://awesome-repositories.com/f/awesome-lists/devtools/algorithm-resources.md) — Implementations of common algorithms and data structures in JavaScript.
- [Development Environments and Tools](https://awesome-repositories.com/f/awesome-lists/devtools/development-environments-and-tools.md) — A collection of fundamental algorithms implemented to improve coding proficiency.
- [System Programming](https://awesome-repositories.com/f/awesome-lists/devtools/system-programming.md) — Collection of fundamental algorithms and data structures.
- [System Utilities](https://awesome-repositories.com/f/awesome-lists/devtools/system-utilities.md) — Collection of fundamental algorithms and data structures.
- [Learning and Reference](https://awesome-repositories.com/f/awesome-lists/learning/learning-and-reference.md) — Algorithms and data structures with explanations.

### Software Engineering & Architecture

- [Algorithmic Performance Optimizations](https://awesome-repositories.com/f/software-engineering-architecture/development-methodologies/performance-optimization-principles/algorithmic-performance-optimizations.md) — Analyzes time and space complexity to ensure efficient data processing and predictable scaling.
- [String Matching Algorithms](https://awesome-repositories.com/f/software-engineering-architecture/string-matching-algorithms.md) — Implements efficient substring search algorithms to minimize redundant character comparisons. ([source](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string))

### Programming Languages & Runtimes

- [Bracket Balancing Algorithms](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/standard-libraries/standard-library-implementations/sequence-algorithms/bracket-balancing-algorithms.md) — Implements bracket balancing algorithms to verify correct nesting and sequence validity. ([source](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/stack/valid-parentheses))
- [Edit Distance Calculators](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/string-utilities/string-manipulators/edit-distance-calculators.md) — Implements algorithms to calculate the minimum edit distance between strings for fuzzy matching and comparison. ([source](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string))

### Artificial Intelligence & ML

- [Classification](https://awesome-repositories.com/f/artificial-intelligence-ml/classification.md) — Implements nearest neighbor classification for predicting data categories based on training datasets. ([source](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/ml))
- [Clustering Algorithms](https://awesome-repositories.com/f/artificial-intelligence-ml/clustering-algorithms.md) — Implements centroid-based clustering algorithms for grouping unlabeled data based on feature similarity. ([source](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/ml))

### Graphics & Multimedia

- [Image Processing](https://awesome-repositories.com/f/graphics-multimedia/media-processing-analysis/media-manipulation/image-processing.md) — Implements content-aware image resizing by removing low-energy pixels to preserve structural integrity. ([source](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/image-processing))

### Testing & Quality Assurance

- [Unit Testing Frameworks](https://awesome-repositories.com/f/testing-quality-assurance/unit-testing-frameworks.md) — Verifies algorithmic logic and correctness using a comprehensive suite of automated unit tests.
