Awesome Open Source
Awesome Open Source

JavaScript Data Structures and Algorithms

deps Coverage Status Build Status Maintainability stars pr license twitter BCH-compliance Greenkeeper badge

I put this repository together to get ready for technical interviews. I hope it helps you get ready for your next big technical interview. If you like what you see plz give it a star. Also, feel free to contribute :D

What is an algorithm?

In simple terms, it is possible to say that an algorithm is a sequence of steps which allow to solve a certain task ( Yes, not just computers use algorithms, humans also use them). Now, an algorithm should have three important characteristics to be considered valid:

  1. It should be finite: If your algorithm never ends trying to solve the problem it was designed to solve then it is useless

  2. It should have well defined instructions: Each step of the algorithm has to be precisely defined; the instructions should be unambiguously specified for each case.

  3. It should be effective: The algorithm should solve the problem it was designed to solve. And it should be possible to demonstrate that the algorithm converges with just a paper and pencil.

Getting Started

  1. Run npm install
  2. Run npm test to run all of the algorithms

This repo covers the following topics:

An algorithm is a self-contained step-by-step set of operations to be performed. Algorithms perform calculation, data processing, and/or automated reasoning tasks.

"Elegant" (compact) programs, "good" (fast) programs : The notion of "simplicity and elegance" appears informally in Knuth and precisely in Chaitin:

Knuth: ". . .we want good algorithms in some loosely defined aesthetic sense. One criterion . . . is the length of time taken to perform the algorithm . . .. Other criteria are adaptability of the algorithm to computers, its simplicity and elegance, etc"

Chaitin: " . . . a program is 'elegant,' by which I mean that it's the smallest possible program for producing the output that it does"


  • Timsort
  • Floyd-Warshall
  • Traveling Salesman
  • k-way merge
  • Matching users to servers, using Gayle-Shapely Algorithm for Stable Marriage problem
    • This is a beautiful algorithm for fair matching. Simple, elegant and effective. In its core form, it’s also straightforward to implement. Has numerous applications. See: Stable marriage problem - Wikipedia
  • A toy implementation of Viterbi algorithm
    • Ubiquitous in cell phone technology, and many other applications, Viterbi algorithm is a Dynamic Programming based algorithm that finds the most likely sequence of states.
    • SSL transport, is the bane of safe existence on Internet these days. One of the most well-known algorithms in secure transport, is RSA, named by the first initials of its inventors. Implementing RSA is fun and instructive e.g. C code to implement RSA Algorithm(Encryption and Decryption)
  • Safe Browsing (or similar) using Bloom filters
    • Bloom filters found very rare usage until the world got more online and we hit scale. But these days, we see new applications very frequently.Chrome browser uses Bloom filters to make preliminary decision on safe browsing. See some novel applications here.
  • Implement an LALR parser
    • As a CS student, you may have already implemented it as part of your compiler’s class. But if not, then you should. LALR parsing makes syntactic sense of source code, whichever language you use. Many implementations of LALR exist. e.g. Where can I find a simple, easy to understand implementation of an LR(1) parser generator? Also, use YACC to understand LALR parsing better.
  • Treemap using Red Black Trees!
    • RB Trees are not algorithms, but they are famed enough, that no discussion of tantalizing DS/Algorithms is complete without discussing them. The smoothest way to see/implement RB Trees, is to look at Treemap implementation in Java.
  • Circle Drawing using Bresenham’s algorithm
    • Ever wondered, how circles are drawn on the screen, with minimal jaggedness (aliasing)? Bresenham’s elegant algorithm is at play here. See a version here: Circle Generation Algorithm . A refreshing use of a similar algorithm, is to make properly sized tabs in Chrome. Something we see almost every day. Such hidden gems!
  • Implement PageRank
    • Can’t miss this. This transformed our lives in ways we never thought possible. Get started here: Pagerank Explained Correctly with Examples


Don't hesitate to create a pull request. Every contribution is appreciated. In development you can start the tests by calling npm test. Checkout our contribution README for more info.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D


Joe Karlsson



Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Javascript (1,535,723
Algorithms (10,950
Data Structures (6,422
Graph (3,931
Array (1,909
Queue (1,745
Tree (1,632
Stack (1,385
Graph Algorithms (950
Linked List (876
Astar (316
Hashtable (281
Dijkstra (212
Breadth First Search (187
Shortest Paths (160
Memoization (156
Sorting Algorithms Implemented (83
Bitwise (58
Binary Heap (56
Related Projects