Repolode
trekhleb

trekhleb/javascript-algorithms

A JavaScript collection of classic algorithms and data structures, each with explanations and further reading links.

Stars
196,685
Forks
31,010
Open issues
413
Last commit
3 months ago

What is it?

This repository implements a wide range of common algorithms and data structures in JavaScript. It covers basic structures such as linked lists, stacks, queues, hash tables and heaps, as well as trees (BST, AVL, red-black, segment and Fenwick trees), graphs, tries, and LRU caches.

The algorithm side is organized by topic (math, sets, strings, searching, sorting, graphs, cryptography, and a few machine learning examples) and by paradigm such as brute force, greedy, divide and conquer, dynamic programming, and backtracking. Each entry is marked by difficulty level and links to its own explanation page.

The repository also includes Big O complexity tables for data structures and sorting algorithms, and provides npm scripts for installing dependencies, running ESLint, and executing tests by name.

Key features

  • 01Implements core data structures including linked lists, heaps, tries, and several tree variants.
  • 02Organizes algorithms by topic and by paradigm such as dynamic programming and backtracking.
  • 03Each algorithm links to a separate explanation page with further reading and video references.
  • 04Includes Big O complexity comparison tables for data structures and sorting algorithms.
  • 05Provides npm scripts for linting and running tests, including filtering tests by name.

Use cases

  • Preparing for technical interviews that test algorithms in JavaScript.
  • Studying how a data structure or sorting algorithm works by reading its implementation.
  • Looking up time and space complexity for common structures and sorts.
  • Using the code as a reference when implementing similar logic in a JavaScript project.

Topics

FAQ

What is javascript-algorithms?
A JavaScript collection of classic algorithms and data structures, each with explanations and further reading links. This repository implements a wide range of common algorithms and data structures in JavaScript. It covers basic structures such as linked lists, stacks, queues, hash tables and heaps, as well as trees (BST, AVL, red-black, segment and Fenwick trees), graphs, tries, and LRU caches.
Is javascript-algorithms free to use? What license does it have?
javascript-algorithms is open source under the MIT license. Check the license terms before using it in commercial products.
Is javascript-algorithms still maintained?
Updated within 6 months. The last commit to javascript-algorithms was on Jul 26, 2026.
What can I use javascript-algorithms for?
Preparing for technical interviews that test algorithms in JavaScript. Studying how a data structure or sorting algorithm works by reading its implementation. Looking up time and space complexity for common structures and sorts. Using the code as a reference when implementing similar logic in a JavaScript project.
Where can I get javascript-algorithms?
The source code and installation instructions are on GitHub: https://github.com/trekhleb/javascript-algorithms

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects