Binary Search Tree ADT for browser and nodejs
npm install binary-search-tree-adt> BinarySearchTree ADT for browser and nodejs
Download the [production version][min] or the [development version][max].
[min]: https://raw.githubusercontent.com/pasangsherpa/binary-search-tree-adt/master/dist/binary-search-tree-adt.min.js
[max]: https://raw.githubusercontent.com/pasangsherpa/binary-search-tree-adt/master/dist/binary-search-tree-adt.js
``sh`
$ npm install --save binary-search-tree-adt
`sh`
$ bower install --save binary-search-tree-adt
`js
var BinarySearchTree = require('binary-search-tree-adt');
var bst = new BinarySearchTree();
``js`
Create an empty tree.
#### .add(element)
Add an element to tree.
##### element
Type: object
the element to be added to the tree.
#### .remove(element) throws "No such element" error
Remove an element from the tree and return the element.
##### element
Type: object
the element to be removed from the tree.
#### .removeAllOccurrence(element) No such element" error
Remove all occurrences of the element from the tree and return the element.
##### element
Type: object
the element to be removed from the tree.
#### .removeMin() throws "Tree is empty" error
Remove the minimum element in the tree and return the element.
#### .removeMax() throws "Tree is empty" error
Remove the maximum element in the tree and return the element.
#### .getRoot()
Returns the root of the tree.
Type: object
the root of the tree
#### .find(element) throws "No such element" error
Find an element from the tree and return the element.
##### element
Type: object
the specified element.
#### .findMin() throws "Tree is empty" error
Find the minimum element in the tree and return the element.
#### .findMax() throws "Tree is empty" error
Find the maximum element in the tree and return the element.
#### .isEmpty()
Returns true if this tree contains no elements.
Type: boolean
whether or not the tree is empty.
#### .size()
Returns the number of elements in the tree.
Type: int`
the number of element in the tree.