# @clarketm/superbinarytree

> BinaryTree with superpowers! 💪

Latest version **1.2.32** (published 2018-11-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @clarketm/superbinarytree
pnpm add @clarketm/superbinarytree
yarn add @clarketm/superbinarytree
bun add @clarketm/superbinarytree
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.32 |
| Published | 2018-11-26 |
| First published | 2018-05-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 30.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Travis Clarke |
| Maintainers | clarketm |
| Keywords | javascript, super, superpowers, BinaryTree, polyfill |

## Links

- npm: https://www.npmjs.com/package/@clarketm/superbinarytree
- Homepage: https://github.com/clarketm/super/tree/master/packages/superbinarytree#readme
- npm.io page: https://npm.io/package/@clarketm/superbinarytree

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.2.32 (latest) — 2018-11-26
- 1.2.31 — 2018-07-26
- 1.2.25 — 2018-07-22
- 1.2.20 — 2018-06-04
- 1.2.18 — 2018-05-22
- 1.2.17 — 2018-05-17
- 1.2.16 — 2018-05-17
- 1.2.15 — 2018-05-17
- 1.2.14 — 2018-05-17
- 1.2.13 — 2018-05-17
- 1.2.11 — 2018-05-17
- 1.2.9 — 2018-05-16
- 1.2.8 — 2018-05-15
- 0.0.0 — 2018-05-15

## README

# [BinaryTree](https://www.npmjs.com/package/@clarketm/superbinarytree)

[![NPM release](https://img.shields.io/npm/v/@clarketm/superbinarytree.svg)](https://www.npmjs.com/package/@clarketm/superbinarytree)

BinaryTree with superpowers! 💪

## Individual Module Installation

### Yarn

```bash
$ yarn add @clarketm/superbinarytree
```

### Npm

```bash
$ npm install @clarketm/superbinarytree --save
```

## API

### `constructor(iterable: Iterable<number>, comparator: Comparator)`

Construct a BinaryTree

### `root: TreeNode`

Get the root of the tree

### `height: number`

Get the height of the tree

### `getHeight(node: TreeNode): number`

Get the height of the tree at node

| Name | Type           | Attribute | Description |
| ---- | -------------- | --------- | ----------- |
| node | BinaryTreeNode |           | root node   |

### `findMin(node: TreeNode): TreeNode`

Find minimum value in tree

| Name | Type           | Attribute | Description |
| ---- | -------------- | --------- | ----------- |
| node | BinaryTreeNode |           | root node   |

### `findMax(node: TreeNode): TreeNode`

Find maximum value in tree

| Name | Type           | Attribute | Description |
| ---- | -------------- | --------- | ----------- |
| node | BinaryTreeNode |           | root node   |

### `insert(value: Item)`

Insert a value into the tree

| Name  | Type | Attribute | Description                   |
| ----- | ---- | --------- | ----------------------------- |
| value | Item |           | value to insert into the tree |

### `search(value: Item): TreeNode`

Search and retrieve a value from the tree

| Name  | Type | Attribute | Description     |
| ----- | ---- | --------- | --------------- |
| value | Item |           | value to search |

### `remove(value: Item)`

Remove a value from the tree

| Name  | Type | Attribute | Description     |
| ----- | ---- | --------- | --------------- |
| value | Item |           | value to remove |

### `preOrder(node: TreeNode): Array<TreeNode>`

Traverse the tree in preOrder traversal ordering

| Name | Type           | Attribute | Description |
| ---- | -------------- | --------- | ----------- |
| node | BinaryTreeNode |           | root node   |

### `inOrder(node: TreeNode): Array<TreeNode>`

Traverse the tree in inOrder traversal ordering

| Name | Type           | Attribute | Description |
| ---- | -------------- | --------- | ----------- |
| node | BinaryTreeNode |           | root node   |

### `postOrder(node: TreeNode): Array<TreeNode>`

Traverse the tree in postOrder traversal ordering

| Name | Type           | Attribute | Description |
| ---- | -------------- | --------- | ----------- |
| node | BinaryTreeNode |           | root node   |

### `levelOrder(node: TreeNode): Array<TreeNode>`

Traverse the tree in levelOrder traversal ordering

| Name | Type           | Attribute | Description |
| ---- | -------------- | --------- | ----------- |
| node | BinaryTreeNode |           | root node   |

### `toArray(traversal: Traversal, flatten: boolean): Array<TreeNode|Item>`

Convert the tree to an array

| Name      | Type      | Attribute | Description                                       |
| --------- | --------- | --------- | ------------------------------------------------- |
| traversal | Traversal |           | method of traversal                               |
| flatten   | boolean   |           | if false return nodes; if true return only values |

## `TreeNode`

TreeNode

### `constructor(value: Item)`

Construct a TreeNode

### `value: Item`

Get the value of node

### `left: TreeNode`

Get the right child node

### `right: TreeNode`

Get the right child node

---
_Source: https://npm.io/package/@clarketm/superbinarytree · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
