ts-bst
v1.0.1
Published
A Binary Search Tree implementation using TypeScript generic classes.
Readme
Binary Search Tree
Implementation in TypeScript
Feel free to read up on them if you are interested.
This lib includes a basic implementation with a few exposed methods. The binary search tree is genericized for whatever data you are trying to store/lookup.
import { BST } from 'ts-bst';
const numBst = new BST<number>();
const strBst = new BST<string>();BST Methods
insert -> void
numBst.insert(4);
numBst.insert(6);
strBst.insert('apple');
strBst.insert('banana');contains -> boolean
const hasValue = numBst.insert(4); // true
const hasOrange = strBst.insert('orange'); // falseminimum -> T
const min = numBst.minimum();
console.log(min === 4); // truemaximum -> T
const max = strBst.maximum();
console.log(max); // 'banana'