This is a `playground`

to test code. It runs a full `Node.js`

environment and already has all of `npm`

’s 1,000,000+ packages pre-installed, including `binary-search-tree-adt`

with all `npm`

packages installed. **Try it out**:

var binarySearchTreeAdt = require("binary-search-tree-adt")

- all documents on RunKit are public
`require()`

any package directly from npm- use arrow functions, classes, template strings, and most of ES6
`await`

any promise instead of using callbacks (example)- create your own embedded
**node.js**snippets

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

BinarySearchTree ADT for browser and nodejs

Download the production version or the development version.

```
$ npm install --save binary-search-tree-adt
```

```
$ bower install --save binary-search-tree-adt
```

```
var BinarySearchTree = require('binary-search-tree-adt');
var bst = new BinarySearchTree();
```

```
<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.

`throws "No such element" error`

Remove an element from the tree and return the element.

Type: `object`

the element to be removed from the tree.

`No such element" error`

Remove all occurrences of the element from the tree and return the element.

Type: `object`

the element to be removed from the tree.

`throws "Tree is empty" error`

Remove the minimum element in the tree and return the element.

`throws "Tree is empty" error`

Remove the maximum element in the tree and return the element.

Returns the root of the tree.

Type: `object`

the root of the tree

`throws "No such element" error`

Find an element from the tree and return the element.

Type: `object`

the specified element.

`throws "Tree is empty" error`

Find the minimum element in the tree and return the element.

`throws "Tree is empty" error`

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.

- package on npmhttps://npmjs.com/package/binary-search-tree-adt
- homepagehttps://github.com/pasangsherpa/binary-search-tree-adt
- licenseMIT

RunKit is a free, in-browser JavaScript dev environment for prototyping **Node.js** code, with every **npm** package installed. Sign up to share your code.

Sign Up for Free