An open API service indexing awesome lists of open source software.

https://github.com/dfernandeza/data-structures-and-algorithms

Implementations for common data structures and algorithms using modern JavaScript.
https://github.com/dfernandeza/data-structures-and-algorithms

algorithms data-structures javascript typescript

Last synced: about 2 months ago
JSON representation

Implementations for common data structures and algorithms using modern JavaScript.

Awesome Lists containing this project

README

          

# Data structures and algorithms (DSA)

![CI passing](https://github.com/dfernandeza/data-structures-and-algorithms/actions/workflows/ci.yml/badge.svg)
![solved coding problems](https://img.shields.io/badge/solved%20coding%20problems-20-success)

This repository contains implementations of common data structures and algorithms using modern JavaScript.

The intention with this repository is not to only serve as a playground to learn DSA (or as a refresher) but also to practice solving different coding problems using DSA.

## Covered data structures

- [x] Array
- [x] Linked list
- [x] Doubly-linked list
- [x] Stack
- [x] Queue
- [x] Tree
- [ ] Trie
- [x] Binary search tree
- [x] AVL tree
- [ ] Red-Black tree
- [x] Binary heap
- [x] Graph

## Covered algorithms

### Sorting

- [x] Bubble sort
- [x] Insertion sort
- [x] Selection sort
- [x] Merge sort
- [x] Quick sort
- [x] Bucket sort
- [x] Counting sort
- [x] Radix sort
- [x] Cycle sort
- [x] Heap sort
- [x] Topological sort (top-sort)

### Searching

- [x] Linear search
- [x] Binary search
- [ ] Interpolation search
- [x] Breadth first search
- [x] Depth first search

### Others

Shortest path

- [x] Dijkstra's
- [ ] Floyd-Warshall
- [ ] Minimum spanning tree (MST)
- [ ] Prim's
- [ ] Kruskal's
- [ ] Bellman–Ford

## Covered algorithms designs and techniques

- [x] Divide and conquer
- [x] Dynamic programming
- [x] Greedy
- [x] Backtracking

## Exploring the code

There are 2 directories `algorithms` and `data-structures` where you can find all the different implementations. Each algorithm and data structure would have a `README` file containing a small description and a list of coding problems that maps to a `*.problems.test.js` file containing the solutions.

## Running your own copy

To run your own copy, fork this repository and execute:

```
npm i
npm test
```

## Running specific tests

You can target specific tests by using the `--testNamePattern` (or `-t`) flag. For example,

To run all the tests related to the `array` data structure, you can execute:

```
npm test -- -t "Array"
```

To run tests the array problem 1, you can execute:

```
npm test -- -t "Array Problem 1"
```

_This project uses [Jest](https://github.com/facebook/jest) for writing the tests and [SWC](https://github.com/swc-project/swc) as the test runner._

## Resources

These are the resources I've been using to sharp my DSA skills in case you are also interested:

- [Learning JavaScript data structures and algorithms [Book]](https://github.com/PacktPublishing/Learning-JavaScript-Data-Structures-and-Algorithms-Third-Edition)
- [Grokking Algorithms [Book]](https://www.manning.com/books/grokking-algorithms)
- [itsy-bitsy-data-structures](https://github.com/jamiebuilds/itsy-bitsy-data-structures/)
- [GeeksforGeeks](https://www.geeksforgeeks.org/data-structures/)