Skip to content

Latest commit

 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaScript Algorithms and Data Structures

My own implementations of common data structures and algorithms in JavaScript. I wrote them to really understand how they work inside instead of only using built-in methods, and to prepare for coding interviews. Every one of them has Jest tests.

Data structures

Name Main methods Code
Linked List add, insert, remove, removeAt, get, toArray LinkedList.js
Stack push, pop, peek, size, isEmpty Stack.js
Hash Table set, get, delete, has, getValue HashTable.js
Heap (max) with heap sort add, remove, sort, find Heap.js
Max Heap add, pop, peek MaxHeap.js
Min Heap add, remove, peek, find MinHeap.js

Algorithms

Name What it does Code
Binary Search Finds an element in a sorted array in O(log n) BinarySearch.js
Kadane's Algorithm Finds the maximum subarray sum in O(n) KadanesAlgorithm.js
Tortoise and Hare (Floyd) Finds the start of a cycle in a linked list TortoiseHare.js

Built with

  • JavaScript (Node.js)
  • Jest for tests

How to run

git clone https://github.com/IkboljonMe/javascript-algorithms.git
cd javascript-algorithms
npm install
npm test

Run tests only for one folder, for example the linked list:

npm test -- linked-list

Plans

  • Queue
  • Binary Search Tree
  • Trie
  • Graph (BFS, DFS)

License

MIT, see LICENSE.


Made by IkboljonMe

About

My own implementations of data structures and algorithms in JavaScript, tested with Jest.

Topics

Resources

Stars

7 stars

Watchers

4 watching

Forks

Releases

Packages

Contributors

Languages