A data structures and algorithms library.
- Queue
- Stack
- Heap
- SLL (singly linked list)
- search
- binarySearch()
- sort
- quickSort()
- bubbleSort()
- insertionSort()
- mergeSort()
- HeapSort()
To install
npm i @skapoor8/mjolnir
Example:
// testStack.js
const {Stack} = require('@skapoor8/mjolnir');
var s = new Stack();
s.push(1);
s.push(2);
s.push(3);
s.pop();
console.log(s.toString());
Run with bash node testStack.js
Output:
[1,2]
- new Stack()
- Stack.push(item)
- Stack.pop()
- Stack.isEmpty()
- Stack.toString()
- new Queue()
- Queue.enqueue(item)
- Queue.dequeue()
- Queue.isEmpty()
- new Heap(compare, order)
- new SLL()
- SLL.push(item)
- SLL.pop()
- SLL.shift(item)
- SLL.unshift()
- SLL.reverse()
- SLL.at(index)
- SLL.put(index, item)
- SLL.map(f)
- SLL.toString()
- SLL.fromArray()
- binarySearch(Array/SLL, searchFunc)
- quickSort()
- bubbleSort()
- insertionSort()
- mergeSort()
- heapSort()
- Well defined interfaces that enforce invariants
- Idiomatic and interchangable interfaces - SLL should be interchangable with JS arrays throughout this lib
- Idiomatic error handling?
- Printing to console?
- Idiomatic interfaces?
- Handling large data sets?
- Add iterators where appropriate
- Typescript bindings
- Add jsDocs
- Add other data structures: set, trees, graphs, dll and cll
- Add unit tests for data structures
- Needs es6 wrapper for browser environments, possibly some polyfills