Common useful algorithms written in modern, pretty and easy-to-understand Javascript. Typescript has been used only for type checking and better auto-documentation, code is in pure ES6.
All the algorithms are also tested using Jest with the help of custom nice-to-read diffs for data structures.
The purpose of this repository is to show algorithms written using declarative and intuitive code as much as possible. It's not meant to be used as production.
If you need something absolutely performant in production try checking felipernb/algorithms.js with low-level optimisations.
Check also this article about pros and cons of common sorting algorithms.
- Counting sort
- Heap sort
- Insertion sort
- Merge sort
- Merge and insertion sort
- Quick sort
- Selection sort
You can play around with the code cloning the repo and running the following commands:
npm install # or yarn install
npm test # or yarn test
Play around with the source code, the tests and learn the algorithms! You can also run the following command to put tests in watch mode and auto-run with changes. Jest CLI output is awesome!
npm run test -- --watch
- Add a real-world usage example of every algorithm
- Add benchmarks