In this post, a developer discusses a GitHub project he has created for furthering knowledge around JS algorithms and data structures.
Join the DZone community and get the full member experience.Join For Free
Jumpstart your Angular applications with Indigo.Design, a unified platform for visual design, UX prototyping, code generation, and app development.
To make this process even smoother I’ve tried to put some graphical illustrations for each algorithm and data structure where it was possible just to make the idea behind those algorithms easy to grasp and memorize.
You also may find some practical information just in the root README file that may be handy while you’re studying. Such information as:
- Big O notation graphs — to see quickly what is worse O(n!) or, let’s say, O(n²)
- list of some of the most used Big O notations and their performance comparisons — to get the idea how big is 10! (it is 3628800)
- data structures operations complexity — how fast are searches, reads or insertions for different data-structures
- comparative table of sorting algorithms complexity — to help you choose proper sorting algorithm in your situation
All code is 100% covered with tests. This is done not only to keep the code working correctly but also to give you an illustration of how each algorithm or data structure works, what basic operations they have (let’s say polling for heap) and what are the edge cases (what to do if the graph is directed).
The repository also has a playground. This is just small function template along with an empty test case that will help you to start testing or working on algorithms right after cloning the repo.
Currently, the following data structures are covered:
- Linked List
- Hash Table
- Priority Queue
- Tree (Binary Search Tree, AVL Tree)
- Graph (both directed and undirected)
- Disjoint Set
On top of these data structures, more than 50 popular algorithms are implemented. Among them are sorting, searching algorithms, and graph/tree/sets/string/math related algorithms. All algorithms are also categorized by their paradigms:
- Brute Force Algorithms — looks at all the possibilities and selects the best solution.
- Greedy Algorithms — choose the best option at the current time, without any consideration for the future.
- Divide and Conquer Algorithms — divide the problem into smaller parts and then solve those parts.
- Dynamic Programming Algorithms — build up to a solution using previously found sub-solutions.
- Backtracking Algorithms — similarly to brute force, this tries to generate all possible solutions but each time you generate a solution test, it only continues generating subsequent solutions if it satisfies all conditions. Otherwise, backtrack and go on a different path to finding a solution.
I hope this repository will be helpful for you! Enjoy coding!
Published at DZone with permission of Oleksii Trekhleb . See the original article here.
Opinions expressed by DZone contributors are their own.