Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/onesy-me/binary-tree

Binary tree
https://github.com/onesy-me/binary-tree

algorithm amaui binary-serach-tree binary-tree browser bst javascript js library node nodejs typescript utils web

Last synced: 10 days ago
JSON representation

Binary tree

Awesome Lists containing this project

README

        



onesy logo

onesy Binary Tree


Binary Tree



MIT license    
Production ready    
UMD 1.9kb gzipped    
100% test cov    
Browser and Nodejs


Very simple code    
Modern code    
Junior friendly    
Typescript    
Made with :yellow_heart:


## Getting started

### Add

```sh
yarn add @onesy/binary-tree
```

### Use cases
- Min/max heaps
- Huffman coding, data compression
- Machine learning, making decisions
- etc.

### Use

```javascript
import { OnesyBinaryTree } from '@onesy/binary-tree';

// Make a new binary tree instance
const onesyBinaryTree = new OnesyBinaryTree();

// Add a onesy node / value
[4, 2, 7, 14, 1, 3, 5].map(value => onesyBinaryTree.add(value));

// or use a make method or a static method
onesyBinaryTree.make([4, 2, 7, 14, 1, 3, 5]);

// Binary tree
4
/ \
/ \
2 7
/ \ / \
1 3 5 14

// Remove any value
onesyBinaryTree.remove(2);

// Binary tree
4
/ \
/ \
3 7
/ / \
1 5 14
```

### Dev

Install

```sh
yarn
```

Test

```sh
yarn test
```

### Prod

Build

```sh
yarn build
```