red-black-bst
v1.0.2
Published
Algs4 BST in javascript
Downloads
15
Readme
Red-Black BST
Implementation of Algs4 Red Black BST in javascript with no dependencies.
This project is an implementation of red-black binary search for multi purpose. Common uses are: data caching, sort, indexing, etc...
Usage
$ npm i red-black-bst
const BST = require('red-black-bst');
const bst = new BST();
bst.put('my key', {mydata: 'is this'})
console.log(bst.get('my key'))
API
CRUD
Methods for create, read, update and delete nodes in tree.
Create or Update
Creating or update node in tree.
bst.put('my key', {mydata: 'is this'})
Read
Get key content in tree.
bst.get('my key')
Delete
bst.delete('my key')
Query
Methods for query in the tree.
min
Get min key in the tree.
bst.min()
max
Get max key in the tree.
bst.min()
rank
Get number of keys less than key queried.
bst.rank('my key')
select
Get data in the by rank position.
bst.select(10)
floor
Get key less then or equal key queried.
bst.floor('my key')
ceilling
Get key greater then or equal key queried.
bst.ceilling('my key')
keys in range
Get all keys between interval keys queried.
bst.keysInRange('first key', 'last key')