binary-search-tree-adt
Version:
Binary Search Tree ADT for browser and nodejs
129 lines (69 loc) • 2.65 kB
Markdown
> BinarySearchTree ADT for browser and nodejs
Download the [production version][min] or the [development version][max].
[]: https://raw.githubusercontent.com/pasangsherpa/binary-search-tree-adt/master/dist/binary-search-tree-adt.min.js
[]: 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
<script type="text/javascript" src="https://raw.githubusercontent.com/pasangsherpa/binary-search-tree-adt/master/dist/binary-search-tree-adt.min.js"></script>
<script type="text/javascript">
var bst = new BinarySearchTree();
</script>
```
Create an empty tree.
Add an element to tree.
Type: `object`
the element to be added to the tree.
Remove an element from the tree and return the element.
Type: `object`
the element to be removed from the tree.
Remove all occurrences of the element from the tree and return the element.
Type: `object`
the element to be removed from the tree.
Remove the minimum element in the tree and return the element.
Remove the maximum element in the tree and return the element.
Returns the root of the tree.
Type: `object`
the root of the tree
Find an element from the tree and return the element.
Type: `object`
the specified element.
Find the minimum element in the tree and return the element.
Find the maximum element in the tree and return the element.
Returns true if this tree contains no elements.
Type: `boolean`
whether or not the tree is empty.
Returns the number of elements in the tree.
Type: `int`
the number of element in the tree.
[](http://opensource.org/licenses/MIT) © [Pasang Sherpa](https://github.com/pasangsherpa)