Binary Tree
Very simple code Modern code Junior friendly Typescript Made with 💛
yarn add @onesy/binary-tree
- Min/max heaps
- Huffman coding, data compression
- Machine learning, making decisions
- etc.
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
Install
yarn
Test
yarn test
Build
yarn build