npm.io
1.2.2 • Published 5 years ago

@structured/binary-tree

Licence
MIT
Version
1.2.2
Deps
0
Size
28 kB
Vulns
0
Weekly
0

@structured/binary-tree

A simple binary tree and so much more.

Installation

yarn add @structured/binary-tree

Usage

import { singleLeft } from '@structured/binary-tree';

let root = {
  data: 'a',
  right: {
    data: 'b',
    right: {
      data: 'c',
    },
  },
}

// Balance the tree with a left rotation!
root = singleLeft(root)
// {
//   data: 'b',
//   left: { data: 'a' },
//   right: { data: 'c' },
// }