binary search tree & avl tree (self balancing tree) implementation in javascript
Package Exports
@datastructures-js/binary-search-tree
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@datastructures-js/binary-search-tree) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@datastructures-js/binary-search-tree
Binary Search Tree & AVL Tree (Self Balancing Tree) implementation in javascript.
Both trees have the same interface except that AVL tree will maintain itself balanced due to rotating nodes that become unbalanced on insertion and deletion. If your code requires a strictly balanced tree that always benefits from the log(n) runtime of insert & remove, you should use AVL.
const bst =newBinarySearchTree();// OR a self balancing treeconst bst =newAvlTree();
.insert(key, value)
inserts a node with key/value into the tree. Inserting an node with existing key, would update the existing node's value with the new one. AVL tree will rotate nodes properly if the tree becomes unbalanced during insertion.